Tagged: c conditional operator

Conditional operator in C 49

Conditional operator in C

Conditional operator in C is also known as ternary operator. It is called ternary operator because it takes three arguments. It evaluates an expression returning a value if that expression is true and different one if the expression is evaluated as false. Syntax: condition ? result1 : result2; If the condition is true, result1 is returned else result2 is returned. Examples: 10==5 ? 11: 12; // returns 12, since 10 not equal to 5. 10!=5 ? 4 : 3; // returns 4, since 10 not equal to 5. 12>8 ? a : b; // returns the value of a, since...

FREE C Cheatsheet - Speed Up Your C Programming.

FREE C Cheatsheet - Speed Up Your C Programming.

Download a 7-page free cheat sheet for easy and quick access to C Concepts, Snippets, and Syntax.

Thank you! Check you inbox and access your cheat-sheet