Learn about Even Odd Program in C Using the Conditional Operator in the below code example. Also refer the comments in the code snippet to get a detailed view about what’s actually happening.
Contents
Even Odd Program in C Using the Conditional Operator
Source code:
#include<stdio.h>
int main()
{
int n;
printf("Enter a positive Number: ");
scanf("%d",&n);
(n%2==0)?(printf("Even")):(printf("Odd"));
return 0;
}
Output:
Enter a positive Number: 45
Odd
Hope above code works for you and Refer the below Related Codes to gain more insights. Happy coding and come back again.
Similar Codes :
Even Odd Program in C Using the Switch case
Even odd program in C using if-else