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

In this example, we learn how to write C program to find the grade obtained by reading marks of students. We will write the C program to find the grade obtained of student. Write a c program to input the roll number and five subjects marks from the user and find grade obtained by reading marks of student. How to find grade from marks of student in c programming. Logic to find grade from marks of students.

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

For example, if a user enters the roll no.: 182540 and marks in 5 subjects are 92,80,94,89 and 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;


}

You have any problem in the above C program to find the grade obtained by reading marks of student. do not hesitate and write your problem in the comment box. I will support your problem.

No comments:

If you have any doubts, Please let me know

Powered by Blogger.