lvalue required as left operand of assignment - remainder of division

2

I have a problem making the rest of the room. You gave this error:

  

value required as left operand of assignment

How do I resolve this?

#include <stdio.h>
#include <stdlib.h>

int main()
{
int x;
printf("informe o numero inteiro: \n");
scanf("%d",&x);
if (x>0)
    {
    printf("numero positivo ");
    }
    else {
        printf("numero negativo ");
    }
if (x % 2 = 0)
{
    printf("e par");
}
    else {
        printf("e impar");
    }

return 0;
}
    
asked by anonymous 02.04.2018 / 20:15

1 answer

3

The comparison signal that will work, = is assignment, == is comparison. In an assignment it can not have an expression on the left side, just a variable, it was lucky this time, the compiler got the error, if it had only one variable it would work, but it would be wrong.

if (x % 2 == 0)
    
02.04.2018 / 20:19