Tạo bởi Trần Văn Điêp|
Lập Trình C

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:

  1. Input student data

  2. Sort, display detailed information, and show statistics of all students

  3. Find students by year of birth

  4. Save to binary file student.dat

  5. 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_st struct pointer as an argument.

  • Stores the input data into the studentList array in the main() 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_st struct 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_st struct 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_st struct pointer as an argument.

  • Creates the file student.dat in binary mode.

  • Writes all student data to the file.

  • Closes the file.


7. Exit

When the user chooses option 5, the program terminates.

Phản hồi từ học viên

5

Tổng 0 đánh giá

Đăng nhập để làm bài kiểm tra

Chưa có kết quả nào trước đó