In this tutorial learn how you can write a c program to check a number odd or even using conditional operator. We are using a test case “<test case>? True value: false value”. 

This is the shortcut form of the if statement. First, write a statement and use “?” as a separator then the first one is a true case and else or false case which is separated by “:”.

C programming is a powerful general-purpose programming language. It can be used to develop software like operating systems, databases, compilers, etc.


write c program to check number odd or even using conditional operator



Write a Program to Check a Number Odd or Even using Conditional Operator

Here is the code to check a number odd or even using a conditional operator in C programming.

#include <stdio.h> //WAP to check  a number odd or even  using conditional operator.
int main(){
int num;
printf("Please enter any number:");
scanf("%d",&num);
(num%2==0)?printf("%d is even.",num):printf("%d is odd.",num);
return 0;
}

Test Live At Jdoodle


Conclusion

This is how you can check a number odd or even using conditional operator in c programming. Comment below if you like our tutorial.