-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheque1.c
38 lines (32 loc) · 1.1 KB
/
cheque1.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
#include <stdio.h>
#include <string.h>
int main()
{
char db[4][4][12] = {
{"ENG23CS0267", "ENG23CS5507", "ENG23CS3423", "ENG23CS2324"},
{"ENG23CS3242", "ENG23CS2432", "ENG23CS1241", "ENG23CS2342"},
{"ENG23CS2134", "ENG23CS1342", "ENG23CS4231", "ENG23CS3421"},
{"ENG23CS4231", "ENG23CS3421", "ENG23CS1342", "ENG23CS2134"}
};
char key[12];
int found = 0; // Flag to track if the key is found
printf("Enter the key: ");
scanf("%s", key);
for(int i = 0; i < 4 && !found; i++) // Iterate over rows
{
for(int j = 0; j < 4; j++) // Iterate over columns
{
if(strcmp(key, db[i][j]) == 0)
{
printf("The given USN is present in the database\n");
found = 1; // Set the flag to indicate that the key has been found
break; // Exit the inner loop once found
}
}
}
if (!found)
{
printf("The given USN is not present in the database\n");
}
return 0;
}