Question #128951

Found and fix errors in the following code:

if(number%2=0)
cout<<"Even.";
else
cout<<"Odd.";

Expert's answer

if(number%2=0)
cout<<"Even.";
else
cout<<"Odd.";

The first string contains an error: the assignment operator is used (=). But we have to use the equality operator (==).


Fixed code is:

if(number%2==0)
cout<<"Even.";
else
cout<<"Odd.";
LATEST TUTORIALS
APPROVED BY CLIENTS