+ 10
My 2nd C++ question in my 12 years life
How many numbers will be printed? for(int a=0; a>=0; a++){ cout<<a<<endl; if ( a > 10){ break; } } I found 11 but the right answer is 12. confused🙈🙉🙊Thanks for your answer‼
4 Réponses
+ 12
I have your answer.It will go for a for loop starting with a=0. The value of a will be incremented every time time. It will print output like
0
1
2
3..so on
There will be a condition when 11 will be greater than 10 and the loop will break there. So it will print 12 number starting with 0 and ending with 11.
+ 14
Yes total 12 numbers will be printed
0
1
2
3
5
6
7
8
9
10
11
When a=11 it first prints it and then checks the condition hence total 12 numbers strting from 0 to 11 will be printed
+ 10
Thanks my unknown friends😺 I got it。
+ 2
12 numbers will be printed as the condition inside the for loop is always true and the loop will finish only when the if condition gets satisfied .. So it will start printing from 0 1 2 3 4 5 6 7 8 9 now when a is 10 it gets printed an the condition is still false then a will be incremented again 11 will be printed and then it will check condition which is true and break will be executed. so 12 numbers in total will be printed