+ 4

Please why is it compiling to 6 and not 5

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

16th Dec 2017, 5:43 AM
Sammy
Sammy - avatar
5 Respostas
+ 9
in your While loop 'num' is getting incremented and the terminating condition is num <6 .. https://code.sololearn.com/cSeBDmmElBRo/?ref=app for printing till 5 refer this..
16th Dec 2017, 5:52 AM
Aaditya Deshpande
Aaditya Deshpande - avatar
+ 8
Because your initial condition is int num = 1 change to num = 0 int main() { int num = 0; while (num++ < 6) { cout << "Number: " << num << endl; }
16th Dec 2017, 5:49 AM
Louis
Louis - avatar
+ 3
thanks everyone. for your help. I appreciate
16th Dec 2017, 6:30 AM
Sammy
Sammy - avatar
+ 1
alright thanks alot
16th Dec 2017, 3:12 PM
Sammy
Sammy - avatar
0
Sir Ace, Please could you drop your email here. I would like to ask you something personally and I need your help . I am sorry for the inconvenience and the fact that sololearn doesn't have a chat platform . I would delete it once I have copied it. thanks Sir. If you don't disclose it also let me know pls.
16th Dec 2017, 6:33 AM
Sammy
Sammy - avatar