Translate

Saturday, April 25, 2020

The else if ladder

The else if ladder

/*Control Statement: else if ladder*/


  • The else if Ladder Statement:
This is a type of nesting in which there is an if...else statement in every else part except the last else part. This type nesting is called the else if Ladder Statement.

The Syntax of else if Ladder:

if(Condition 1)
       Statement A;
else if(Condition 2)
         Statement B;
 else if(Condition 3)
              Statement C;
  else if(Condition 4)
                Statement C;
       else
                 Statement D;

The Example of else if Ladder :

#include<stdio.h>
#include<conio.h>
void main()
{
    float per;
  
    printf("Enter your percentage = ");
    scanf("%f",&per);
    if(per>=85)
    printf( "grade B");
    else if(per>=70)
    printf( "grade B");
    if(per>=55)
    printf( "grade ='C'");
    else if(per>=40)
    printf( "grade D");
    else
    printf("Fail");
    getch();
       
}

Output:





No comments:

Post a Comment

C program to make a calculator using the switch statement.

/*perform arithmetic calculation on integers in C language*/ #include<stdio.h> #include<conio.h> void main() {     char op;     ...