if else if else statement

The syntax of the if..else if..else is as follows:

if(expression1){ 
  // statement1 
}else if(expression2){
  // statement2
}else if(expression3){
  // statement3
}else{
  // statements to be executed if all test expressions are false 
}

The if...elseif..else statement executes two different codes depending upon whether the test expression is true or false. Sometimes, a choice has to be made from more than two possibilities. The nested if...else if..else statement allows you to check for multiple test expressions and execute different codes for more than two conditions.

#include
#include
void main(){
  int m;
  clrscr();
  scanf("Enter a number = %d",m);
  if(m == 5){
    printf("Enter number is 5");
  }else if(m == 15){
    printf("Enter number is 15");
  }else if(m == 25){
    printf("Enter number is 25");
  }else{
    printf("Enter number is not 5,15 or 25");  
  }
 getch();
}

Output

Enter a number = 24
Enter number is not 5,15 or 25