C Ternary Operator

C ternary operator is a shorthand of combination of if and return statement. Syntax of ternary operator are as follows:
(expression1 ) ? expression2: expression3
If expression1 is true it returns expression2 otherwise it returns expression3. This operator is a shorthand version of this if and return statement:
1.if(expression1)
2.return expression2;
3.else
4.return expression3;

source:cprogramlanguage.net

No comments:

Post a Comment