-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPrintGrade.c
More file actions
executable file
·40 lines (33 loc) · 1.13 KB
/
Copy pathPrintGrade.c
File metadata and controls
executable file
·40 lines (33 loc) · 1.13 KB
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
#include <stdio.h>
void main()
{
//A is right !!!
char Name[30][40] = {"Sammy Matthews", "Mary McBeth", "Ying Phakpon","Chai Chanchai", "Yong Boonsith", "Kitti Karndee"};
intsn ID[30] = {5301, 5302, 5303, 5304, 5305, 5306};
float GPA[30] = {2.73, 2.35, 3.65, 3.24, 1.32, 3.26};
int N = 6, i;
int SearchID, found_index;
printf("\nSTUDENT GPA LIST: \n");
printf("ID----Name------------------------GPA\n");
for (i=0;i<N; i++)
printf("%5d %-25s %5.2f\n", ID[i], Name[i], GPA[i]);
printf("-------------------------------------\n");
printf("Enter Student ID to Search (0 to End): ");
scanf("%d", &SearchID);
while (SearchID)
{
found_index = -1;
for (i = 0; i<N && found_index == -1; i++)
if (SearchID == ID[i])
found_index = i;
if (found_index == -1)
printf("Sorry, Student ID %5d not found.\n", SearchID);
else
printf("ID: %5d. Name: %-25s. GPA: %5.2f.\n",
ID[found_index], Name[found_index], GPA[found_index]);
printf("Enter Student ID to Search (0 to End): ");
scanf("%d", &SearchID);
}
pritnf("Edited by A\n");
printf("Bye Bye\n");
}