for

Posts 1–8 of 8 · Page 1 of 1
for
In my C++ book, i see alot of

[php]for(int i = 0; i < 5; i++){
-Stuff here-
}[/php]

Is the 'i' in the for statement just a variable that makes the 'stuff here' loop 5 times? or is it 6 times.

Dont bother telling me my syntax is wrong either.

/
Quote Originally Posted by Kallisti View Post
In my C++ book, i see alot of

[php]For(i = 0, i < 5, i++)
-Stuff here-[/php]

Is the 'i' in the for statement just a variable that makes the 'stuff here' loop 5 times? or is it 6 times.

Dont bother telling me my syntax is wrong either.

/
For(i = 0; i < 5; i++){
cout<<i<<endl;
}

and you have your answer... :P
First of all the "For" must write with small letter be "for". Than you must change the "," to ";" and the i must be declared as DWORD or integer Variable. And the answer is it loops 4 times. Because < 5 is smaller than 5. It´s 4...
correctly it looks like so:

Code:
for(int i = 0; i < 5; i++){
Regards
Quote Originally Posted by inmate View Post
First of all the "For" must write with small letter be "for". Than you must change the "," to ";" and the i must be declared as DWORD or integer Variable. And the answer is it loops 4 times. Because < 5 is smaller than 5. It´s 4...
correctly it looks like so:

Code:
for(int i = 0; i < 5; i++){
Regards
Code:
0 <-
1    |
2    |-- Loops 5 times :P
3    |
4 <-
'i' is a variable.
Lol. I knew my syntax was off xD.
Thats what i thought, just wanted to make sure /

edit: fixed syntax errors
/Rekwest Kloze
Posts 1–8 of 8 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Talk with us