“C Program Using Ternary Operator To Check Even Odd”
This is a C program that uses conditional operator in C programming language to check whether a number is even or odd.
Ternary operator is called conditional operator in C programming language. The syntax of ternary operator is as follows:
(condition)? true-case-statement : false-case-statement;
Example of using ternary operator in c programming language is:
It is equivalent to if else statement:
Now since x>10 condition is true so 1 will be assigned to ans variable. If the condition is wrong then zero will be assigned to variable ans.
Source code of checking even odd program using conditional or ternary operator is as follows:
545 total views, 6 views today