c-programs-basics
In the previous program, we have seen how to calculate total marks and average, in this program we will see how to give grades according to the marks be obtained, using the ladder if statement.
We will refer to the following Chart of percentage and grades.
Percentage
Grades
>=80
A+
>=75
A
>=60
B
>=45
C
>=35
D
<35
Fail

C Program To Give Grades According To Mark Obtained

#include<stdio.h>
#include<conio.h>
void main()
{
 int s1,s2,s3,s4,s5,t,p;
 clrscr();

 printf("\n Enter marks of 5 subjects each out of 100 ");
 printf("\n\n ********************************************");

 printf("\n\n Maths = ");
 scanf("%d",&s1);

 printf("\n Science = ");
 scanf("%d",&s2);

 printf("\n English = ");
 scanf("%d",&s3);

 printf("\n History = ");
 scanf("%d",&s4);

 printf("\n Geography = ");
 scanf("%d",&s5);
 printf("\n ********************************************");

 t=s1+s2+s3+s4+s5;  //Total
 printf("\n Total marks = %d/500",t);

 p=t/5;  //Percentage
 printf("\n\n Percentage = %d%",p);
 printf("\n ********************************************");

//////////// Ladder If Statement ////////////
 if(p>=80)
    printf("\n\n Your Grade : A+");

   else if(p>=75)
     printf("\n\n Your Grade : A");

     else if(p>=60)
       printf("\n\n Your Grade : B");

        else if(p>=45)
          printf("\n\n Your Grade : C");

            else if(p>=35)
              printf("\n\n Your grade : D");

   else
     printf("\n\n You Are Fail");

 //////// Ladder If Statement /////////////

 getch();
}

Output : 
c-program-to-find-grades-output
This way we have written a c program to find grades using an else if ladder statement.