C Conditional Statement

C programming supports following conditional statement and operators.

Statement Description
if () { } An if statement consist of a condition statement followed by one or more statement. Statements can be exexuted when condition is true.
If() { } else { } An if statement can be followed by an else statement which can be executed when condion is false.
If (){ } else if () { } …  else  { } An if else ladder . this can will execute only that statement whose condition is true  otherwise else condition will be executed default.
 Switch () { case .. :   … .. } A switch statement is used to check for equality of variable again set of case values.
? : Conditional operator

Example 1:



a has value as 10

Example 2:

output :

a  and b are not equal

Example 3:

output :


Example 4:



Default statement will be executed then only when no case is matched.