0% found this document useful (0 votes)
1 views5 pages

Assignment On Algorithm

The document outlines five algorithms for different tasks: validating user input for a number between 1 and 3, categorizing a child's age, calculating the all-tax price of items based on tax-free price and TVA rate, determining the product sign of two numbers, and ensuring a number is between 10 and 20. Each algorithm includes user prompts and conditional statements to guide the flow of execution. The algorithms demonstrate basic programming concepts such as loops, conditionals, and arithmetic operations.

Uploaded by

7hjypr77zt
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views5 pages

Assignment On Algorithm

The document outlines five algorithms for different tasks: validating user input for a number between 1 and 3, categorizing a child's age, calculating the all-tax price of items based on tax-free price and TVA rate, determining the product sign of two numbers, and ensuring a number is between 10 and 20. Each algorithm includes user prompts and conditional statements to guide the flow of execution. The algorithms demonstrate basic programming concepts such as loops, conditionals, and arithmetic operations.

Uploaded by

7hjypr77zt
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

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

You might also like