#include<stdio.h>
#include<conio.h>
main()
{
3>2 ? printf("TRUE") : printf("FALSE");
getch();
}
/*The condition 3>2 is true.Hence the first printf() statement is executed*/
In this program, the conditional operator (ternary operator) is used to determine whether the condition 3 > 2 is true or false. The syntax of the conditional operator is:
condition ? statement_1 : statement_2;
The condition is evaluated first. If the condition is true, then statement_1 is executed, otherwise statement_2 is executed. In this program, the condition 3 > 2 is true, so the first printf statement “TRUE” is executed. The program outputs “TRUE”.
Thanks
Write a program to use the conditional operator with two statements.