+ 2
I have inserted one code in my description. Can anyone please explain how does it work.? I mean how does computer calculates it.
2 ответов
+ 2
This is how it works:
a is initialized with 1 and b with 2.
Enters the while loop.
The condition in the while loop asks if the value of b when incremented (3) is less than 5:
Be cause the condition is true the value of b will be multiplied by the value of a (3* 1 = 3) and assigned to a.
the next iteration, the while condition asks if b incremented (4) is less than 5.
because it is true the value of b (4) will be multiplied to the value of a (3) and the result assigned to a. (=12)
next iteration, while condition is 5 < 5 which is false. The loop ends. the value of a is printed (12).
+ 1
thank u @ulisses cruz