Write a program to input sum of 5 subjects and display percentage and division

To find percentage, divide the sum of marks obtained in each subject by total marks and then  multiply by 100. For division, if percentage>60, "first division", if percentage>=45 and less than 60, "second division", if percentage>=30 and less than 45, "third division" else fail.

#include<stdio.h>
void main()
{
   int sci, math, eng, hin, comp, sum, total=500;
   float per;
  
   printf("Enter marks obtained in five subjects");
   scanf("%d %d %d %d %d", &sci, &math, &eng, &hin, &comp);
   
   sum= sci+math+eng+hin+comp;
   printf("\nSum=%d",sum);
   per=(sum/500)*100;
   printf("Percentage obtained is %f",per);
   
   if(per>=60)
   printf("\nFirst division");
   else if(per>=45 && per<60)
   printf("\nSecond division");
   else if(per>=30 && per<45)
   printf("\nThird division");
   else
   printf("\n Fail");
  }
   
     

Post a Comment

0 Comments