+ 2

plz tell me why and how its output is 12

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

5th Jan 2018, 5:25 PM
PRO
PRO - avatar
4 Answers
+ 1
plz reply fast
5th Jan 2018, 5:27 PM
PRO
PRO - avatar
+ 1
my expectation of output was 20 ...because if number and total were added 5 times it would give result as 20..why isnt the output 20
5th Jan 2018, 5:34 PM
PRO
PRO - avatar
+ 1
The loop runs 5 times. In each iteration the value of number is added to the value of total. If you add 2 five times to 2, the result is 2 + 2*5 which is equal to 12.
5th Jan 2018, 5:41 PM
Shadow
Shadow - avatar
0
ohh....thanks....
5th Jan 2018, 5:45 PM
PRO
PRO - avatar