Thursday, August 30, 2018

9. WAP to find the grade a student gets based on the average number obtained.

9. WAP to find the grade a student gets based on the average number obtained.
          Avg | Grade
-------------------------
        >=85 |   A
        >=75 |   B
         >=65 |   C
         >=55 |   D
         >=45 |   E
         <45    |   F


#include<stdio.h>
#include<conio.h>
void main()
{
   float eng,maths,phy,chem,comp,avg;
   printf("Enter marks obtained in English: ");
   scanf("%f",&eng);
   printf("Enter marks obtained in Mathematics: ");
   scanf("%f",&maths);
   printf("Enter marks obtained in Physics: ");
   scanf("%f",&phy);
   printf("Enter marks obtained in Chemistry: ");
   scanf("%f",&chem);
   printf("Enter marks obtained in Computer: ");
   scanf("%f",&comp);
   avg=(eng+maths+phy+chem+comp)/5;
   printf("\nAverage number obtained - %.1f",avg);
   if(avg>=85)
   {
    printf("\nGrade - A");
   }
   else if(avg>=75)
   {
    printf("\nGrade - B");
   }
   else if(avg>=65)
   {
    printf("\nGrade - C");
   }
   else if(avg>=55)
   {
    printf("\nGrade - D");
   }
   else if(avg>=45)
   {
    printf("\nGrade - E");
   }
   else
   {
    printf("\nGrade - F");
   }
   getch();
}



OUTPUT:








Please have a look at the below video lesson posted on my YouTube channel:

No comments:

Post a Comment