-
Notifications
You must be signed in to change notification settings - Fork 0
/
studentmanager.c
102 lines (88 loc) · 2.61 KB
/
studentmanager.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#include<stdio.h>
#define MAX_STUDENTS 3
struct student{
char name[30];
int age;
enum Score{
A,B,C,D,F
}score;
}s[MAX_STUDENTS];
int main(){
int choice,list,n;
n=0;
do{
scanf("%d",&choice);
switch(choice){
case 1:
if (n < MAX_STUDENTS) {
scanf("%s", s[n].name);
scanf("%d", &s[n].age);
char score;
scanf(" %c", &score);
switch (score) {
case 'A':
s[n].score = 0;
break;
case 'B':
s[n].score = 1;
break;
case 'C':
s[n].score = 2;
break;
case 'D':
s[n].score = 3;
break;
case 'F':
s[n].score = 4;
break;
default:
printf("Invalid score. \n");
break;
}
printf("Student added successfully.\n");
n++;
} else {
printf("Maximum number of students reached.\n");
}
break;
case 2:
printf("List of students:\n");
for(int i=0;i<n;i++){
printf("Student %d\n",i+1);
printf("Name: %s\n",s[i].name);
printf("Age: %d\n",s[i].age);
switch (s[i].score){
case 0:
printf("Score: A\n");
break;
case 1:
printf("Score: B\n");
break;
case 2:
printf("Score: C\n");
break;
case 3:
printf("Score: D\n");
break;
case 4:
printf("Score: F\n");
break;
default:
printf("enter valid grade\n");
break;
}
}
break;
case 3:
printf("Highest-scoring student:\n");
break;
case 4:
printf("Exiting the program. Thank you for using our system!\n");
break;
default:
printf("Invalid choice. Please enter a valid option.\n");
break;
}
}while(choice!=4);
return 0;
}