Write a C program to check whether a number is even or odd using conditional operator.
#include <stdio.h> int main() { int num;
printf("Enter any number to check even or odd: "); scanf("%d", &num); (num%2 == 0) ? printf("The number is EVEN") : printf("The number is ODD"); return 0; }
#include <stdio.h>
int main()
{
int num;
printf("Enter any number to check even or odd: ");
scanf("%d", &num);
printf("The number is %s", (num%2==0 ? "EVEN" : "ODD"));
return 0;
}
No comments