Mode:
Duration:
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
#include <stdio.h>
#include <string.h>
struct Student {
int id;
char name[50];
float marks;
};
struct Student s[100];
int count = 0;
void addRecord() {
printf("Enter ID, Name, Marks: ");
scanf("%d %s %f", &s[count].id, s[count].name, &s[count].marks);
count++;
}
void displayRecords() {
int i;
for (i = 0; i < count; i++) {
printf("ID: %d, Name: %s, Marks: %.2f\n", s[i].id, s[i].name, s[i].marks);
}
}
void searchRecord() {
int id, i, found = 0;
printf("Enter ID to search: ");
scanf("%d", &id);
for (i = 0; i < count; i++) {
if (s[i].id == id) {
printf("Found -> ID: %d, Name: %s, Marks: %.2f\n", s[i].id, s[i].name, s[i].marks);
found = 1;
break;
}
}
if (!found)
printf("Record not found\n");
}
int main() {
int choice;
while (1) {
printf("\n--- MENU ---\n");
printf("1. Add Record\n");
printf("2. Display Records\n");
printf("3. Search Record\n");
printf("4. Exit\n");
printf("Enter choice: ");
scanf("%d", &choice);
switch (choice) {
case 1:
addRecord();
break;
case 2:
displayRecords();
break;
case 3:
searchRecord();
break;
case 4:
return 0;
default:
printf("Invalid choice\n");
}
}
}Coding works best on desktop or with an external keyboard.