Search This Blog

Translate

relational/conditional operator/ternary operator in c example

relational operator in c,conditional operator in c example,ternary operator in c example,file operations in c example program,conditional operator in c programming,conditional operator in c with example,conditional operator example in c





CONDITIONAL OPERATOR

Conditional Operator (?:) is ternary operator (demands 3 operands), and is used in certain situations, replacing if-else condition phrases. Conditional operator’s shape is:


Condition_phrase?phrase1 : phrase2;

If conditional_phraseis true, phrase1 is executed and whole phrase is assigned with value of this phrase1. If the conditional phrase is false, then phrase2 is executed, and whole phrase is assigned with phrase2 value.

Example:
int a, b, c;
c = a > b ? a : b; // if a>b "execute" a, else b




relational operator in c,conditional operator in c example,ternary operator in c example,file operations in c example program,conditional operator in c programming,conditional operator in c with example,conditional operator example in c

C Program example List

Google+ Badge