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");
}
0 Comments