-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRFID_for_Students_Attendance.c
49 lines (37 loc) · 1.3 KB
/
RFID_for_Students_Attendance.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
#include <stdio.h>
#include <stdbool.h>
#define MAX_STUDENT_COUNT 100
typedef struct {
int studentID;
bool present;
} StudentAttendance;
void initializeStudentAttendance(StudentAttendance* attendance, int studentCount);
void markStudentPresent(StudentAttendance* attendance, int studentID);
int main() {
int studentCount;
int studentID;
printf("Enter the number of students: ");
scanf("%d", &studentCount);
StudentAttendance attendance[MAX_STUDENT_COUNT];
initializeStudentAttendance(attendance, studentCount);
printf("Enter the student ID to mark as present: ");
scanf("%d", &studentID);
markStudentPresent(attendance, studentID);
return 0;
}
void initializeStudentAttendance(StudentAttendance* attendance, int studentCount) {
for (int i = 0; i < studentCount; i++) {
attendance[i].studentID = i + 1;
attendance[i].present = false;
}
}
void markStudentPresent(StudentAttendance* attendance, int studentID) {
for (int i = 0; i < MAX_STUDENT_COUNT; i++) {
if (attendance[i].studentID == studentID) {
attendance[i].present = true;
printf("Student with ID %d marked as present.\n", studentID);
return;
}
}
printf("Student with ID %d not found.\n", studentID);
}