1 - Write an algorithm that asks the user for a number between 1 and 3 until the answer is right:
Start
Enter the variable (N) :
Read 1
Read 3
If N>1 and N<3
Print N
End
START
Read 1
Read 3
N<1
N>3
Yes
Print N
End
2- Let's write an algorithm that asks the user the age of a child afterwards, informing him of the
category:
Start
Write "Enter the child’s age: "
Read age
If age >= 12 Then
Write "Cadet"
Else if age >= 10 Then
Write "Minime"
Else if age >= 8 Then
Write " Pupille"
Else if age >= 6 Then
Write " Poussin"
End
Yes we can design many algorithms corresponding to this same result.
Start
yes
age >=
Cadet
12
no
age >= yes Minime
10
no
yes
age >=
8 Pupille
no
age >= yes
6 Poussin
End
3- Let’s write a program that reads the TFP price of an item, the number of items and the TVA
rate, and provides the corresponding all-tax price and making the wording clear.
Variables ni (number of items), tfp (tax-free price), tvar (TVA rate), atp (all-tax price)
Start
Write " tax-free price:"
Start
Read tfp
Write "number of articles:"
Read na
Read tfp
Write "TVA rate:"
Read tvar
Read na
Atp = na * tfp * (1 + tvar)
Write "the all-tax price is: ",
Read tvar
Atp = na * tfp * (1 +
tvar)
Read atp
Read atp
End
End
Start
4-
Variables m, n
start Read m
write "two numbers : "
Read m
Read n
Read n
if m = 0 or n = 0 then
write "The product is zero" M=0 yes
The
else if (m < 0 ET n < 0) OU (m > 0 ET n > 0) then N=0 product is
write "The product is positive" zero
else no
Write "The product is negative" yes
The product is M<0 n<0
End positive
M >0 n>0
no
The product is
negative
End
5-
Variable N
Start
start
write "Enter a number between 10 and 20"
while N < 10 or N > 20
N<10 Number is too big!
read N
if N < 10 then
write "number is too big !" Number is to
N>20 small!
else if N > 20 then
Write "number is too small!"
End End