#include <stdio.h>
int main()
{
int x;
printf("Input x: "); scanf("%d", &x);
if ((x > 0) || (x % 2 == 0))
printf("x is either positive or even.\n");
else
printf("Invalid values of x detected!\n");
return 0;
}
This example is the same as before except the highlighted part. We now use or
operator instead and change the message.
We then again try running this example a few times with the same input:
-2, -1, 0, 1, and 2.
Their respective output was:
x is either positive or even.
Invalid values of x detected!
x is either positive or even.
x is either positive or even.
x is either positive or even.