mod manipulation of an array trouble

help,

I can't figure out why this will not work. I am trying to get my loop to cycle through an array checking each variable against 'mod 2'. If array variable mod 2 produces a '0' (being a multiple of 2) then it should replace that number in the array with a zero. Seems simple enough but for some reason I am not getting the correct output. Any help would be appreciated.

Thanks.



#include <iostream>
using namespace std;

int main ()
{
int size = 12;
int the_array [] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};

for ( int i = 0; i < (size - 1); i++)
{

int multiplier = 2;
int a = 0;

if(a = (the_array[i] % multiplier ))
the_array[i] = 0;

cout << the_array[i] << endl;
}


return 0;
}
try compare ( == ) not equal ( = ).
if(a == (the_array[i] % multiplier ))
worked like a charm. thanks much.
Topic archived. No new replies allowed.