C program to find the grade obtained by reading marks of a student

C program to find the grade obtained by reading marks of a student:

Here I shared C program of performing to find the grade obtained by reading 5 subject marks of a student using else-if ladder statement.


For example,if user enter the roll no.: 182540 and marks in 5 subjects are 92,80,94,89 amd 91 then the output will be:



Enter the roll no:-182540
Enter marks in 5 subject 

92
80
94
89
91

rollno of student =182540

marks in subject1=92
marks in subject2=80
marks in subject3=94
marks in subject4=89
marks in subject5=91
total marks in subject=446
total percentage in subject=89.199997
total grade in subject=B

#include<stdio.h>
int main()
{
  int i,m1,m2,m3,m4,m5,rollno,tot;
  float perc;
  char grade;

      for(i=1;i<=5;i++) 

{

        printf("\n Enter the roll no:-");


         scanf("%d",&rollno);


        printf("\nenter marks in 5 subject");


         scanf("%d%d%d%d%d",&m1,&m2,&m3,&m4,&m5);


        tot=m1+m2+m3+m4+m5;


        perc=(float)(tot/5.0);


      if(perc>=90)


      {


       grade='A';


      }


      else


      {


       if(perc>=80)


       {


        grade='B';


       }


       else


       {


        if(perc>=70)


         {


          grade='C';


         }


        else


         { 


        if(perc>=50)


        {


         grade='D';


        }


        else


        {


         if(perc>=36)


         {


          grade='E';


         }        


         else


         {


          grade='F';


         } 

}

       }

}

     }

       printf("\nrollno of student =%d",rollno);


       printf("\nmarks in subject1=%d",m1);

       printf("\nmarks in subject2=%d",m2); 


       printf("\nmarks in subject3=%d",m3);


       printf("\nmarks in subject4=%d",m4);


       printf("\nmarks in subject5=%d",m5);


       printf("\ntotal marks in subject=%d",tot);


       printf("\ntotal percentage in subject=%f",perc);


       printf("\ntotal grade in subject=%c\n",grade);

} 

  return 0;


}



NOTE: You have any problem in above C Program do not hesitate and write your problem in the comment box. I will support your problem.

Share this

0 Comment to "C program to find the grade obtained by reading marks of a student"

Post a Comment