In this program user ask to define the ternary operator. User declares some required variables that contain values in it. Ternary operator denote by ?: this can be used as a shortcut for an if-else statement. Here user declare a condition to evaluate the method user ask to enter the value. b= (a>5?1:0); and display result on the screen as output.
This is C program that ask user to define the ternary operator.
- Declare the variables.
- Using method to evaluate the condition.
- Display result on the screen.
Here is C source code for using ternary operator. The output of this program shown below.
printf("enter any value ");