Program to find 5 subject marks and calculate percentage and division of student using nested else-if and logical operators.
#include <stdio.h>
#include <conio.h>
void main()
{
int a, b, c, d, e, sum, total = 100;
float perc;
clrscr();
printf ("Enter your marks of 5 subjects: \n");
scanf ("%d%d%d%d%d", &a, &b, &c, &d, &e);
sum = a + b + c + d + e;
perc = (sum*100)/total;
printf ("The percentage of your marks is: %d \n", perc);
if (total>=80)
printf ("You've got 1st Division.");
else if (total>=60)
printf ("You've got 2nd Division.");
else if (total>=40)
printf ("You've got 3rd Division.");
else
printf ("You are FAIL!");
getch();
}
#include <stdio.h>
#include <conio.h>
void main()
{
int a, b, c, d, e, sum, total = 100;
float perc;
clrscr();
printf ("Enter your marks of 5 subjects: \n");
scanf ("%d%d%d%d%d", &a, &b, &c, &d, &e);
sum = a + b + c + d + e;
perc = (sum*100)/total;
printf ("The percentage of your marks is: %d \n", perc);
if (total>=80)
printf ("You've got 1st Division.");
else if (total>=60)
printf ("You've got 2nd Division.");
else if (total>=40)
printf ("You've got 3rd Division.");
else
printf ("You are FAIL!");
getch();
}