### C++ for loop infinite

Hello all..
I am currently stuck on this for loop.. When ran, it keeps going and I need to stop.. Thanks in advance!

 ``1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465`` `````` FOR (i=0; i<199; i++) { FOR (J=0;J<500; J++) IF (J=0) { DIST_WALKED = INIT_WALK_DIST + J } ELSE { DIST_WALKED = DIST_WALKED + ([(i * 214013 + 2531011)%2147483647] % 200) + 100; } // DETERMINE DIRECTION OF WALK IF (MOD(J) = 7) { DIRECTION = COMPASS_PREV * COMPASS_PREV2 *COMPASS_PREV3 * COMPASS_PREV4 * (COMPASS_INDEX) } ELSE { DIRECTION = COMPASS_NEXT * COMPASS_NEXT2 * COMPASS_NEXT3 * COMPASS_NEXT4 * (COMPASS_INDEX) } // DETERMINE XY COORDINATES IF (DIRECTION = "N" || DIRECTION = 2) { POS_X = POS_X + ( DIST_WALKED * COMPASS_NEXT * COMPASS_NEXT2 * COMPASS_NEXT3 * COMPASS_NEXT4(COMPASS_INDEX)) POS_Y = POS_Y } IF (COMPASS_INDEX = 1 || COMPASS_INDEX = 3) { POS_X = POS_X POS_Y = POS_Y + ( DIST_WALKED * COMPASS_NEXT * COMPASS_NEXT2 * COMPASS_NEXT3 * COMPASS_NEXT4(COMPASS_INDEX)) } // CALC DIST FROM HOME DIST_HOME = sqrt((HOME_X - POS_X)^2 +(HOME_Y-POS_Y)^2); //CALC DIST FROM NICK DIST_NICK = sqrt((NICK_X - POS_X)^2 +(NICK_Y-POS_Y)^2); //CHECK PROXIMITY TO HOME if (DIST_HOME <= 30 && J > 5) { cout<<"You are home!"<= 5280) { DIST_HOME = DIST_HOME /5280; } // CHECK PROXIMITY TO NICKS if (DIST_NICK <= 50) { cout<<"You are close to Nick's house!"<= 5280) { DIST_NICK = DIST_NICK / 5280; } } ``````
Hello.

You're mixing up '=' and '=='.
a=2 'a' will be 2.
if(a == 2) {
//means if 'a' is the same as 2.
//do something, if 'a' is 2 and only 2.
}
It won't change 'a'.

Regards
Last edited on
that was my issue!