Connecting Tech Pros Worldwide Help | Site Map

For loop help

Newbie
 
Join Date: Dec 2006
Posts: 1
#1: Dec 20 '06
Ok, all I need to know is how to use 2 variables in a for loop. My code is as follows:

for( int i = row + 1, k = col + 1; i > -1, k < 8; i--, k++)

Its for an othello program Im wrighting and the error is- ; expected
Any help would be greatly apprectiated, thanks.
Lives Here
 
Join Date: Sep 2006
Posts: 12,070
#2: Dec 20 '06

re: For loop help


Quote:

Originally Posted by yoshi

Ok, all I need to know is how to use 2 variables in a for loop. My code is as follows:

for( int i = row + 1, k = col + 1; i > -1, k < 8; i--, k++)

Its for an othello program Im wrighting and the error is- ; expected
Any help would be greatly apprectiated, thanks.


Expand|Select|Wrap|Line Numbers
  1.  
  2. for(int i = row + 1,  k = col + 1 ; (i > -1) && (k < 8); i--, k++)
  3.  
use the && for boolean part.
Lives Here
 
Join Date: Sep 2006
Posts: 12,070
#3: Dec 21 '06

re: For loop help


Is the loop doing what you wanted it to do then?
Reply