Quản lý sinh viên 2 - Assigment - Lập trình C
1. Data
Declare a structure:
struct student_st {
char fullname[30];
char rollNo[10];
int year;
float mark;
};
In the main() function, declare an array of 3 students named studentList.
2. Menu-Based Program
Create a menu-driven program with the following options:
-
Input student data
-
Sort, display detailed information, and show statistics of all students
-
Find students by year of birth
-
Save to binary file
student.dat -
Exit
3. Input Student Data
When the user chooses option 1, perform the following:
Example:
Enter data of student 1:
Full name: Nguyen Van An
Roll Number: C1101h2398
Year of birth: 1991
Mark (/10): 7
This module must be implemented in a separate function that:
-
Has a
student_ststruct pointer as an argument. -
Stores the input data into the
studentListarray in themain()function.
4. Sort, Display Information, and Statistics
When the user chooses option 2:
-
Sort students in descending order by mark.
-
Display detailed information of each student in the following format:
No || Name || Roll Number || Year || Mark || Status ||
001 || Nguyen Van An || C1101h2398 || 1991 || 7.00 || CREDIT ||
002 || Vu Van Binh || C1010h2511 || 1990 || 6.50 || CREDIT ||
003 || Do Thanh Hai || C1105i0125 || 1992 || 2.50 || FAIL ||
Display the number of students by status, for example:
CREDIT has 2 students
FAIL has 1 student
Status is defined based on mark:
-
≥ 7.5 → DISTINCTION
-
≥ 6.0 → CREDIT
-
≥ 4.0 → PASS
-
< 4.0 → FAIL
This module must be implemented in a separate function that:
-
Has a
student_ststruct array as an argument.
5. Find Student by Year of Birth
When the user chooses option 3:
-
Display:
Enter year for search: -
Find and display detailed information of students with the entered year of birth (using the same format as in section 4).
-
If no student is found, display:
There are no students with this year of birth.
This module must be implemented in a separate function that:
-
Has a
student_ststruct array as an argument.
6. Save to Binary File
When the user chooses option 4:
-
Save all student information to a binary file named
student.dat.
This module must be implemented in a separate function that:
-
Has a
student_ststruct pointer as an argument. -
Creates the file
student.datin binary mode. -
Writes all student data to the file.
-
Closes the file.
7. Exit
When the user chooses option 5, the program terminates.