-
Iteration
What is the value of variable i and of variable j on line 4 below:
Code:
Line Code
1 j=0;
2 for(i=0; i<10;i+=3)
3 j=j+2;
4 // What is the value of variable i and variable j?
Is this how it iterates:
i j
0 0
3 2
6 4
9 6
therefore i=9 and j=6 ?????
-
What happened to just trying it out?
-
Check for yourself by printing them out. Note that line 4 is after the loop.
-
unfortunatley i dont have a compiler
but i think i get it.
i = 0
j = 2
i = 3
j = 4
i = 6
j = 6
i = 9
j = 8
Therefore j = 8 i = 12
at uni we use linux and i think C90 compiler. where can i get a compiler similar to that but for windows vista