Tagged: conditional operator in c programming

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 Programming Cheatsheet

FREE C Programming Cheatsheet


Cheatsheet for a quick glance at C programming concepts and syntax

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