What is the value of variable i and of variable j on line 4 below:
Is this how it iterates: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?
i j
0 0
3 2
6 4
9 6
therefore i=9 and j=6 ?????
This is a discussion on Iteration within the C Programming forums, part of the General Programming Boards category; What is the value of variable i and of variable j on line 4 below: Code: Line Code 1 j=0; ...
What is the value of variable i and of variable j on line 4 below:
Is this how it iterates: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?
i j
0 0
3 2
6 4
9 6
therefore i=9 and j=6 ?????
What happened to just trying it out?
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
I support http://www.ukip.org/ as the first necessary step to a free Europe.
Check for yourself by printing them out. Note that line 4 is after the loop.
C + C++ Compiler: MinGW port of GCC
Version Control System: Bazaar
Look up a C++ Reference and learn How To Ask Questions The Smart Way
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