Home / Programs / ? :,Conditional Expression or ternary operator, same program in simple manner
Programming Example

? :,Conditional Expression or ternary operator, same program in simple manner

👁 1,224 Views
💻 Practical Program
📘 Step by Step Learning
Study this program carefully to understand the logic, output, and explanation in a structured way.

Program Code

#include"stdio.h"
int main()
{
int num;

printf("Enter the Number : ");
scanf("%d",&num);

(num%2==0)?printf("Even \n"):printf("Odd \n");

}

Output

Enter the Number : 45
Odd
Press any key to continue . . .

How to learn from this program

First read the algorithm, then study the program code line by line. After that, compare the code with the output and finally go through the explanation. This approach helps learners understand both the logic and the implementation properly.