# IF statement

• 08-11-2006
Cdrwolfe
IF statement
I always seem to have trouble getting the right balance on if statements which contain AND's and OR's.

whats wrong with this

IF (Env[j] == 1 && POPinit[i][j] == 1 || Env[j] == 1 && POPinit[i][j] == 4)

basically TRUE when Env = 1 and POPinit is a 1 or 4 aswell.

But it doesn't seem to work at all any ideas?
• 08-11-2006
kuphryn

Kuphryn
• 08-11-2006
Cdrwolfe
tried that didn't work
• 08-11-2006
itsme86
Why not:
Code:

`if(Env[j] == 1 && (POPinit[i][j] == 1 || POPinit[i][j] == 4))`
Checking Env[j] twice is unnecessary.
• 08-11-2006
Cdrwolfe
thanks, just realised there may have been a problem earlier on the code.

int Env[0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,
0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,
0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0];

does this actually create an array Env[180] filled with the above? i'am guessing now it doesn't.
• 08-11-2006
pianorain
Heh...just guessing, but it looks like you're declaring a 0-length array there. The comma operator ignores the lho and returns the rho.
• 08-11-2006
itsme86
You want: int Env[180] = { 0, 0, 1, ......... };
• 08-11-2006
Cdrwolfe
thanks