Algorithmic I Ch 4 : Iterative structure – 6) Exercise 2 - Part 2 of 4 2023/2024
Exercise 2 : (Course)
Write in algorithmic language a treatment for :
1- Display the sum of integer numbers that are between 1 and 100.
2- Display the even integers which are between 1 and 80 (then the odd numbers).
3- Display all natural numbers multiple of 5 that are between 1 and 100 using the 'for' loop
and the 'while' loop.
4- Display the sum of 10 integer numbers as well as their average.
5- Display the sum of n integer numbers (n>0) as well as their average.
6- Read an integer x>0, then double it as many times until it exceeds 60.
7- Display the minimum between 10 integer numbers.
8- Display the minimum between n integer numbers (n>0).
9- Calculate the sum of several given integer numbers and stop as soon as the sum
exceeds 500, then display their average.
10- Calculate the sum of several given integers, and stop when entering -1, display their
average.
Solution :
4)
S 0;
For i1 to 10 step 1 do
Print(ʺGive an integer :ʺ);
Read(x);
SS+x;
EndFor;
Avg S / 10 ;
Print(ʺS=ʺ, S, ʺ Avg=ʺ, Avg);
5)
Repeat
Print(ʺGive n ˃0 :ʺ); Read(n);
Until (n˃0);
S 0;
For i1 to n step 1 do
Print(ʺGive an integer:ʺ); Read(x);
SS+x;
EndFor;
Avg S / n ;
Print(ʺS=ʺ, S, ʺ Avg=ʺ, Avg);
6)
Repeat
Print (“Give an integer > 0 :“); Read(x) ;
Until (x>0) ;
While(x<=60) do
xx*2 ;
EndWhile ;
Print (“x=“, x);
Page 1 sur 1