|
|
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 = 1, high = 0, low = 100; float percent; cnt = 1; total = 0; do { printf("\nEnter marks for subject %d : ", cnt); scanf("%d", &marks); total += marks; if(marks > high) high = marks; if(marks < low) low = marks; cnt++; }while(cnt <= 5); percent = total / 5.0; printf("\nTotal = %d Percentage = %f", total, percent); printf("\nHighest = %d Lowest = %d", high, low); return 0; } |
|
|
|
|
|
|
|