Write a C Program to demonstrate Ternary operator or Conditional operator.
Ternary operator is used for decision making in place of longer if and else conditional statements.
The ternary operator take three arguments:
- The first is a comparison argument
- The second is the result upon a true comparison
- The third is the result upon a false comparison
int a ,b;
printf(“Enter two numbers : \n”);
a>b?printf(“%d is BIG \n”,a) : printf(“%d is BIG\n”,b);
For improvement of your coding skills we give some tasks along this. If you solve this tasks and send to our email (email@example.com) with your details. We will display your details(like Name, City, college, photo) in our site.
Task: Write a c program to check given number is even or odd using Ternary operator.