ADS_I-SW_02
ADS_I-SW_02
Exercise 01 :
Answer with “true” or “false” to the following instructions and correct any errors:
7) if nbr est Positif then 8) if A <> B et C then 9) if [N >0] et [N < 10] then
... ... ...
endif endif endif
Exercise 02 : Write the algorithm that finds and displays the maximum and minimum of three entered
integer values.
Exercise 03 : Write an algorithm that calculates and displays the absolute value of any integer read from
keyboard.
Exercise 04 : Write the algorithm which allows you to enter a number then determine if it belongs to a
given interval, knowing that the ends(limits) of the interval are fixed by the user.
Exercise 05 : Write the algorithm that allows you to enter the day, month and year of a date (the month
given as a number), to determine if it is a valid date and then display it by transforming the number of the
month into its name (for example March 3, 2012)
Note: use the “case / switch” statement for the last part.
Exercise 06 (Exam 2022-2023): Given a date read from the keyboard as a 5 or 6 digit integer (see
examples) representing a date from the 21st century. Write an algorithm that decodes the given date and
displays the number of the day, month and year on 4 digits.
Examples : date = 270622 ------> Day number : 27 | date = 51109 ------> Day number : 5
Month number : 6 | Month number : 11
Year : 2022 | Year : 2009
1
Exercise 07 : (Exam 2013/2014) : Write an algorithm that asks for a date in the form of 3 integers (day,
month number and year) and displays the season (ex: 02/12/2008; winter of 2008). (We will assume that
the first day of the season is always the 21st)
Exercise 08 : Propose two variations an algorithm that asks the user for a child’s age. Then, inform the
user about the child’s category as follows:
1. "Poussin" from 6 to 7 years old.
2. "Pupille" from 8 to 9 years old.
3. "Minime" from 10 to 11 years old.
4. "Cadet" for ages 12 and older.
Exercise 09 : (Exam 2017/2018) : In a company, the calculation of paid leave days is carried out as
follows: if a person has joined the company for less than a year, they are entitled to two days of leave per
month (at least 1 month), otherwise at least 28 days. If this person is an executive, if he is at least 35 years
old, and if his seniority is greater than 3 years, he is granted 2 additional days. If he is an executive and if
he is at least 45 years old and if his seniority is greater than 5 years, he is granted 4 additional days, in
addition to the 2 granted for over 35 years.
1. Write an algorithm that calculates the number of days of leave from age expressed in years, seniority
expressed in months and membership in executives (being an executive or not).
Exercise 10 : A year is “leap” (that contains 366 days) if it is a multiple of 4, except the years at the start
of the century (which end in 00) which are not leap years unless they are divisible by 400.
Example: - 1980 and 1996 are leap years because they are divisible by 4.
- 2000 is a leap year because it is divisible by 400.
- 2100 and 3000 are not leap years because they are not divisible by 400.
Write an algorithm that allows you to determine whether a given positive integer is a leap year or not.
Exercise 11 : A bank is open from 8:00 to 12:00 and from 14:00 to 17:00 except Thursday afternoon and
Friday all day.
1. Write an algorithm that asks the user to enter a day (weekday) and time (in hours) and displays the
message "Your bank is open" if the bank is open, and "Sorry, your bank is closed" otherwise.
2. Update the previous algorithm to indicates when and at what time the user can return if the bank is
closed.