Accept marks obtained in 5 subjects in a loop, calculate the percentage and determine the highest and lowest marks.

#include <stdio.h>

int main(void)
{
int marks, total, cnt, high = 0, low = 100;
float percent;

total = 0;

for(cnt = 1 ; cnt <= 5 ; cnt++)
{
printf("\nEnter marks for subject %d : ", cnt);
scanf("%d", &marks);

total += marks;

if(marks > high) high = marks;
if(marks < low) low = marks;
}
percent = total / 5.0;

printf("\nTotal = %d Percentage = %f", total, percent);
printf("\nHighest = %d Lowest = %d", high, low);


return 0;
}

No comments:

Post a Comment

kiss on google ads if you are anonymous because your ip is trackable.thank you.

......from.admin