explain output | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

explain output

can somebody explain why this outputs as 12?: int f=1, i=2; while(++i<5) { f*=i; } cout<<f; thanks!

10th Jan 2017, 7:22 PM
Jack Clare
Jack Clare - avatar
3 Answers
+ 3
Yes, you're right ;)
10th Jan 2017, 8:37 PM
visph
visph - avatar
0
ah i think i understand now, but please feel free to correct me if this reasoning is wrong i increments to 3 3*1 = 3 i increments to 4 3*4 = 12 and then it terminates bc i would no longer be <5
10th Jan 2017, 7:32 PM
Jack Clare
Jack Clare - avatar
- 2
दिए गए कोड टुकड़े का आउटपुट क्या है int f=1, i=2; while(++i<5) f*=i; cout<<f;
13th Jul 2020, 11:20 AM
Madan Kkashyap
Madan Kkashyap - avatar