Ternary Operators in C

Posted By on September 27, 2016

Download PDF
Order of Precedence in C

Download PDF

The ? (ternary condition) operator is a more efficient form for expressing simple if statements. It has the following form:

  expression1 ? expression2:  expression3

It simply states:

if expression1 then expression2 else expression3

For example to assign the maximum of a and b to z:

  z = (a>b) ? a : b;

which is the same as:

  if (a>b)
				 z = a;

Download PDF

movie Julian Schnabel: A Private Portrait

Order of Precedence in C

Download PDF

Posted by Akash Kurup

Founder and C.E.O, World4Engineers Educationist and Entrepreneur by passion. Orator and blogger by hobby

Website: http://world4engineers.com