+ 2

I have inserted one code in my description. Can anyone please explain how does it work.? I mean how does computer calculates it.

https://code.sololearn.com/c0bDRtHTA7f1/?ref=app

15th May 2017, 4:48 PM
Harsh
Harsh - avatar
2 Respostas
+ 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).
15th May 2017, 5:04 PM
Ulisses Cruz
Ulisses Cruz - avatar
+ 1
thank u @ulisses cruz
16th May 2017, 3:31 AM
Harsh
Harsh - avatar