c language ternary operator

w‮al.ww‬utturi.com
c language ternary operator

In c language, question mark and semicolon constitute ternary operators.

conditions? Execute when the condition is true: Execute when the condition is false
Value=condition? Value when condition is true: value when condition is false

x <20 ? x++ : x--;

is equal to :

if (x < 20) { 
	x++; 
} 
else { 
	x--; 
}
Created Time:2017-08-28 06:56:44  Author:lautturi