Thursday, January 20, 2011

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:

if(expression1)
return expression2;
else
return expression3;

Dont Miss Another Post Connect With Us !

Enter your email address:

0 comments: