Professional Documents
Culture Documents
Lab 02
Lab 02
EXERCISE 1
Write a program that calculates the BMI of a person.
Formula : bmi=weight /height2 such as the weight is in Kg and the height is in m.
EXERCISE 2
Calculate the price of a certain number of photocopies by applying the following tariff : the first
10 cost 1 euro/piece, the next 20 cost 0.5 euro/piece et all the others cost 0.25 euro/piece (save
the invariable numbers in constants)
EXERCISE 3
We want to pack N eggs in NB boxes of 12 eggs each. Determine, without using any division,
the number NB of boxes (completely filled, to be sealed), as well as the remaining number of
free eggs (the division will be simulated by successive subtractions).
EXERCISE 4
Write an algorithm that allows the clients of a restaurant to make an order. The program must
display the following menu :
The menu will appear as long as the customer wants to add a dish. When the customer finishes
his order the program must display the amount of his invoice.
EXERCISE 5
Write a program that calculates the following sums. The integer is entered by the user.
S1 = 1 + 2 + 3 + ... + N
S2 = 1^1+ 2^2+ 3^3+ ... + N^n
P = 1 * 2 * 3 * ... * N
EXERCISE 6
Write a program that asks the user to enter 20 numbers then displays the maximum and
minimum.
EXERCISE 7
Read a series of 30 grades between 0 and 20, then display the lowest, the greatest,
the number of grades <10, and the number of grades >=10
EXERCISE 8
Write a program that displays the following triangle for N=5 (N is entered by the user):
1
12
123
1234
12345
EXERCISE 9
Write a program that displays the following square for N=5 (N is entered by the user) :
OXOXO
OXOXO
OXOXO
OXOXO
OXOXO