+ 2
Give and explain the output of the following? int main () { int i, n = 4; for (i = 0; i++<n; i++) cout<<i<<"i"; }
9 odpowiedzi
+ 5
i is set to zero in the beginning , the condition is checked first (i++<n) and while checking the codition i is "incremented" by 1.. so now the value of i is "1"...the loop runs for the first time,and 1i is displayed in the console and i is incremented again after the end of loop..now i="2",loop runs again and "i" gets incremented again while checking for the condition (i++<n) ,now i="3" and 3i is displayed the console and as the loop ends ,"i" gets incremented again but now i is 4 which means i++ should be 5..and 5 is not less than 4 so loop will not run again..program ends here after returning zero
+ 2
1i3i
You can try to run the code in the Code Playground and see how it works :)
+ 2
n=4 i i <=n i++(i=i+1)
0 true 1
1 true 2
2 true 3
3 true 4
4 true 5
false
It prints value of i on the screen till the condition is satisfied i.e. 0 1 2 3 4
0
I didn't get u
- 1
"first u learn english"@sukhvinder
- 1
the output will be
1 i
3 i
- 2
Помогите, гайд по c++
- 2
it is i
- 5
I am not understand