0

Why the output is 20? (for loop)

int a=0, b=20; for(;a<b;a++); cout<< a; Why the result is 20? Shouldnt it be 01234567...1516171819? I'm confused plz help

9th Jan 2020, 4:31 PM
Oscar
3 Answers
+ 2
ditch the semicolon at the end of the for loop
9th Jan 2020, 4:35 PM
MO ELomari
+ 1
Oh you are right! This question is quite tricky to me. So the semicolon immediately end the loop? Thanks for answering!!
9th Jan 2020, 4:49 PM
Oscar
+ 1
yes, In C and C++, a semicolon acts as a statement terminator.
9th Jan 2020, 4:59 PM
MO ELomari