0

How is answer generated to 12?

What is the output of the following code? int f=1, i=2; while(++i<5) { f*=i; } cout<<f;

20th Jan 2017, 6:49 PM
christopher Parge
christopher Parge - avatar
2 Respostas
+ 8
i=2 i=i+1<5==true&&i==3 f = 3 i=i+1<5==true&&i==4 f = 12
20th Jan 2017, 6:55 PM
Valen.H. ~
Valen.H. ~ - avatar
0
the output of this would be 12. each time in a while loop i is incremented by 2 and then checked whether it is less than 5 or not.. and in the loop f*=i; mean f=f*i;
20th Jan 2017, 6:58 PM
Dawood Shahat
Dawood Shahat - avatar