Let’s consider the following algorithm :
A=0
B=0
while B<=50 do
A=A+1
B=A²
Endwhile
print(’A=’)
1. Complete this array of numbers, giving the different steps of the algorithm.
2. What is the value printed at the end of the algorithm ?
3. Describe by a sentence, what this algorithm calculates.
We have a bag containing 1 euro coins whose thickness is 2.33 mm. A miniature Eiffel Tower is 3 cm high.
We stack the coins and stop when it exceeds the height of the miniature Eiffel Tower.
We note H the variable representing the height of the stacking and N the number of coins.
1. Complete the following algorithm so that it calculates the number of coins necessary to achieve this stacking.
N = 0
H = 0
while H<=... do
N = ...
H = ...
Endwhile
print (...)
2. What is the result given by the algorithm ?
3. Modify this algorithm to print the height of the stacking. What is this height ?
On average, an adult cat eats 200 to 300 grams of mash, and 70 grams of kibble per day. Lola worries, finds that her packet of kibble contains only 540 grams of kibble.
Write an algorithm using a "whileloop" to let Lola know in how many days, she will absolutely have to buy kibble for her cat.
The lines are :
A 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8
B 0 | 1 | 4 | 9 | 16 | 25 | 36 | 49 | 64
B<=50 : True | True | True | True | True | True | True | True | False
The value printed at the end of the algorithm is 8.
This algorithm determines the smallest integer whose square is greater than 50.
N = 0
H = 0
while H<=30. do
N = N+1
H = H+2.33
Endwhile
print (N)
2. The result given by the algorithm is 13.
3. Last line : print (H). This height is 30.29 mm.
N=0
K=0
while K<540 do
K=K+70
N=N+1
endwhile
print(N-1)