-
Notifications
You must be signed in to change notification settings - Fork 0
/
program.c
47 lines (44 loc) · 1.27 KB
/
program.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <stdio.h>
int main()
{
int num, n=1, option;
float c_total=0, phy_total=0, c=0, d=0;
printf("How many students?");
scanf("%d", &num);
for (int i=1; i<=num; i++){
int a=0, b=0;
printf("Enter the marks obtained by student %d in the following subjects:\n", i);
printf("C Programming: ");
scanf("%d", &a);
printf("Physics: ");
scanf("%d", &b);
c_total += a;
phy_total += b;
if (c<a)
c=a;
if (d<b)
d=b;
}
while (n=1){
printf("\n\n******************************\n");
printf("Select an operation\n");
printf("1. Print highest marks\n");
printf("2. Print average\n");
printf("3. Exit\n");
printf("******************************\n");
scanf("%d", &option);
if (option == 1){
printf("C highest: %.2f\n", c);
printf("Physics highest: %.2f", d);
}else if (option == 2){
printf("Average in C: %.2f\n", c_total/num);
printf("Average in Physics: %.2f", phy_total/num);
}else if (option == 3){
printf("Goodbye");
break;
}else{
printf("Invalid choice");
}
}
return 0;
}