Mega Code Archive

 
Categories / C Tutorial / Statement
 

The if-else-if statement

The general format for the if-else if statement is: if (condition 1)    simple or compound statement   else if (condition 2)    simple or compound statement   else if ( condition 3)    simple or compound statement      ..... else if ( conditon n )    simple or compound statement #include <stdio.h> main(){   int i = 2;   if(i == 0){      printf(" i == 0. \n");   }else if(i == 1){      printf(" i == 1. \n");   }else if(i == 2){      printf(" i == 2. \n");   } } i == 2.