+ 3
its very confusing...its answer should be 10 ...why is it 8????
5 Answers
+ 3
plz help me fast
+ 3
here you have three variables num number and total with values 2,2, and 0 respectively..
now in the loop.. u r checking that
while num <=5
total+=number;
num++
so when num=2;
total=0+2=2
when num=3;
total=2+2=4;
when num=4
total=4+2=6;
when num=5;
total=6+2 i.e 8.
now when num=6
loop terminates and final output is 8.
+ 2
ver..āŗāŗššššy very thanks to sami khan and ace ....u explained it very well...
0
You should take for num = 1 instead of 2.