Algorithm Exercises for IRT License 2
Algorithm Exercises for IRT License 2
License 2 - IRT
2020-2021
I- Exercises on reading and writing operations
Exercise 1:
Write the algorithm to calculate and display the net salary of an employee. Knowing that:
Exercise 2:
We are looking to write an algorithm that displays the multiplication table of a number n.
any. Example: n = 9
1*9=9
2 * 9 = 18
3 * 9 = 27
4 * 9 = 36
5 * 9 = 45
6 * 9 = 54
7 * 9 = 63
8 * 9 = 72
9 * 9 = 81
Write an algorithm that asks for a starting number, and then displays the ten numbers.
following. For example, if the user enters the number 17, the program will display the numbers from
18 to 27.
Exercise 2:
We want to write an algorithm that calculates the sum of positive integers less than or equal to N.
1
Algorithmic
License 2 - IRT
2020-2021
Exercise 3:
Write an algorithm that successively asks the user for 10 numbers and then tells them
then which was the largest among these 10 numbers:
Enter number 1: 7
Enter number two: 24
.......etc.
Entrez le nombre numéro 10 : 13
The greatest of these numbers is: 24
Exercise 4:
Exercise 5:
Write an algorithm that asks for 10 integers, counts the number of positive integers entered, and
display this result.
Exercise 6:
X X X X
X X X X
X X X X
X X X X
X X X X
X X X X
X X X X
X X X X
Exercise 7:
The population of Alpha city is 1,000,000 residents and it is increasing by 50,000 residents.
per year. The city of Beta has a population of 500,000 inhabitants and it increases by 4% per year. Write a
algorithm to determine in how many years the population of the city Beta
will surpass that of the Alpha city.
Exercise 8:
2
Algorithmic
License 2 - IRT
2020-2021
• The number of these divisors.
• The sum of the divisors of this number.
Exercise 9:
Write an algorithm to display the first terms of the following sequences (number of terms (n)
asked the user:
Arithmetic sequence: Un+1 = Un+ 2, U0 = 1
Write an algorithm that asks the user for the water temperature and displays its state (solid,
liquid, vapor.
Exercise 2:
Let's write an algorithm that specifies whether a triangle ABC is right-angled (and if so, at which point).
or if it is not.
Note: According to the converse of the Pythagorean theorem, if AB 2= AC 2+ BC,2then the triangle
ABC is a rectangle at C.
Exercise 3:
Write an algorithm and then a flowchart to find and display the smallest one.
value among three distinct real numbers A, B, and C.
Exercise 4:
Write an algorithm that asks the user for a real number and displays its absolute value (without using
of predefined function obviously).
Exercise 5:
Write an algorithm that asks the user to enter the grade and displays the mention as follows:
3
Algorithmics
License 2- IRT
2020-2021
Exercise 6:
Exercise 7:
Exercise 8:
Write an algorithm that declares and fills an array of 7 real numeric values.
setting everything to zero.
Exercice 2:
Write a procedure that searches for the index of a value in an array V of dimension N.
component containing the value X. First consider the case where we are sure that X is in
the vector, then the general case.
Exercise 3:
Exercise 4:
4
Algorithmics
License 2- IRT
2020-2021
Write an algorithm that allows the user to enter the grades of a class. The program,
Once the input is completed, return the number of these grades that are above the class average.
Exercise 5:
What do the following algorithms do?
a)
Var i, n (10) integer
Debut
n [0] ← 1
For i going from 1 to 9 Do
N(i) ← n (i-1) + 2
End
b)
Exercise 6:
Exercise 7:
Write an algorithm to input 100 values and sort them as they are entered.
table
Exercise 8:
Ecrire un algorithme qui calcule le plus grand écart dans un tableau d’entiers. Rappel : l’écart
The absolute value of the difference between two integers x and y is |x − y|.
5
Algorithmic
License 2 - IRT
2020-2021