error: expected identifier or '(' before 'while' [closed]

-2

I recieved an error when executing the following code, where is the error?

int I= 0;
int J= 0;
int M[10][10];
 while (I<10) {
     J= 1;
     while (J<10) {
        if (((M[I][J] % 2)==1) and (M[I][J]= M[I][J] * 2))
            J= J+2;

     }
     I= I+1;
  }
    
asked by david 22.03.2018 в 15:29
source

1 answer

6
if (((M[I][J] % 2)==1) and (M[I][J]= M[I][J] * 2))

In C, the reserved word and does not exist.

The logical operators of the language are:

  • && - > and logical.

  • || - > or logical.

  • ! - > not logical.

Change your code by

if (((M[I][J] % 2)==1) && (M[I][J]= M[I][J] * 2))
    
answered by 22.03.2018 в 15:44