0
How to write a program using ternary operator in C++?
show the way to make a program to find whether the given number is odd or even using ternary operator.
2 ответов
+ 1
thanks
0
MADE OF GOD
below is syntax for ternary operator :
(condition) ? (code to be executed if condition is true ) : (code to be executed if condition is false)
let me give you example:
int a = 10;
int b = 20;
int c = a<b ? a : b ;
with this, c becomes 10...
if a is 5 and b is 3, c becomes 3
Odd or even can be checked with modulo by 2...
Hope with this, you will be able to do it