C language for the preparation of student performance management system

  • 2020-06-01 10:40:20
  • OfStack

C language is used to write the code of student performance management system for your reference. The details are as follows

C language student achievement management system of practical teaching https: / / www ofstack. com article / 154767. htm

(1) give a description of the selected course design topic and the specific functional requirements to be completed in this topic.

1. Course design topic: student grade management system

2. Functional requirements:

(1). Main functions:

1-- student input

2-- student inserts

3-- student enquiries (by student number)

4-- students delete

5-- student output

6-- calculate the average score of each student and output

7-- calculate the average score of each subject and output

8-- rank the average score of students

9-- calculate the passing rate of each course and output

10-- output the make-up examination list of each subject (including student number, name and score)

11-- sort the students by their student Numbers

0 - exit

Additional features

The user name is admin, and the password is key. When the program is running, the user name and password will be prompted for input. If the input is correct, a menu will be displayed before the operation can begin

(2). Program list


#include<stdio.h>
#include<string.h>
#define max 100/* The maximum value of a given array of structs */
int size = 0;// The global variable 

/* Displays information about student attributes */
typedef struct studentInformation
{
 char student_name[20];/* Student's name */ 
 char student_class[20];
 int student_number;/* Student's student number */ 
 float student_eng;
 float student_math;
 float student_C;
}information;

void menu()
{
 printf("\n");
 printf("********************************\n"); 
 printf("  Student grade management system \n"); 
 printf("********************************\n"); 
 printf("**************************************\n");
 printf(" 1--- Students enter  \n");
 printf(" 2--- Students insert  \n");
 printf(" 3--- Students query  \n");
 printf("     4--- Students to delete  \n");
 printf(" 5--- Students output  \n");
 printf(" 6--- Calculate the average score of each student and output  \n");
 printf(" 7--- Calculate the average score for each subject and output it  \n");
 printf(" 8--- Rank the average score of the students  \n");
 printf(" 9--- Statistics of the passing rate of each course and output  \n");
 printf(" 10--- Output the make-up examination list of each subject (including student number, name and score)  \n");
 printf(" 11--- Sort the students by their student Numbers  \n"); 
 printf(" 0--- exit  \n");
}

//1--- Students enter 
void add_student(information im[], int geshu)
{
 int i;
 int count = size + geshu;
 
 for(i = size; i < count; i++)
 {
 printf(" Please enter the student's name: \n"); 
 scanf("%s",im[i].student_name);

 printf(" Please enter the student's student number: \n");
 scanf("%d",&im[i].student_number);
 
 printf(" Please enter the student's class: \n"); 
 scanf("%s",im[i].student_class);
 
 printf(" Please enter the students' English scores: \n"); 
 scanf("%f",&im[i].student_eng);
 
 printf(" Please enter the students' math scores: \n"); 
 scanf("%f",&im[i].student_math);
 
 printf(" Please enter the student's C Language scores: \n"); 
 scanf("%f",&im[i].student_C);
 
 size++;
 }/*end of for*/ 
}

// Students insert ( Insert by position )
void st_insert(information im[],int index)
{ 
 int i;
 if(index < 1 || index > size + 1){
 printf(" error !\n");
 return;
 }
 for(i = size; i > index-1 ; i--)
 {
 im[i] = im[i - 1];
 }
 printf(" Please enter and insert the student's name: \n"); 
 scanf("%s",im[i].student_name);

 printf(" Please enter the student's student number: \n");
 scanf("%d",&im[i].student_number);
 
 printf(" Please enter the inserted student's class: \n"); 
 scanf("%s",im[i].student_class);
 
 printf(" Please input the students' English scores: \n"); 
 scanf("%f",&im[i].student_eng);
 
 printf(" Please enter the inserted students' math scores: \n"); 
 scanf("%f",&im[i].student_math);
 
 printf(" Please input the student's C Language scores: \n"); 
 scanf("%f",&im[i].student_C);
 size += 1; 
 printf(" Insert the success !\n");
}

//3--- Students query 
void check_oneStudent(information im[], int student_number)
{
 int i,j;
 
 /* Is the realization of student information query */
 for(i = 0; i < size; i++)
 {
 if(im[i].student_number == student_number)
 {
 printf(" The name  = %s\t Student id  = %d\t The class  = %s\t English  = %0.2f\t Math scores  = %0.2f\tC Language performance  = %0.2f\n\n",
 im[i].student_name,im[i].student_number,im[i].student_class,im[i].student_eng,im[i].student_math,im[i].student_C);
 return ;
 }/*end of if*/
 }/*end of for*/ 
 
 printf(" There is no information about the student! \n");

}

//4--- Students to delete 
void del_studentinfor(information im[],int student_number)
{
 int i,j;
 
 /* Find the given number and delete the information for that number */
 for(i = 0; i < size; i++)
 {
 /* Find the corresponding number by comparison and delete it */ 
 if(im[i].student_number == student_number)
 {
 /* Remove information by moving array elements */ 
 for(j = i; j < size - 1; j++)
 {
 im[j] = im[j+1];
 } /*end of for*/ 
 size--;
 printf(" Delete the success !\n");
 return ;
 }/*end of if*/ 
 }/*end of for*/ 
 
 printf(" No student \n");
}

//5--- Students output 
void check_student(information im[])
{
 int i;
 if(size == 0){
 printf(" No student information! ");
 }
 for(i = 0; i < size; i++)
 {
 printf(" The name  = %s\t Student id  = %d\t The class  = %s\t\n English  = %0.2f\t Math scores  = %0.2f\tC Language performance  = %0.2f\n\n",
 im[i].student_name,im[i].student_number,im[i].student_class,im[i].student_eng,im[i].student_math,im[i].student_C);
 }/*end of for*/ 
}

//  Calculate the average score of each student and output 
void aveGrade(information im[])
{
 int i;
 float ave = 0;
 
 for(i = 0;i < size;i++)
 {
 ave = (im[i].student_eng + im[i].student_math + im[i].student_C)/3;
 printf(" Student id %d The name %s Average score  = %0.2f\n",im[i].student_number,im[i].student_name,ave);
 }
}

// Average score of each subject and output 
void ev_grade(information im[]){
 int i,j = 0;
 float sum1 = 0.0,sum2 = 0.0,sum3 = 0.0;
 
 for(i = 0;i < size;i++)
 {
 sum1 = sum1 + im[i].student_eng; 
 sum2 = sum2 + im[i].student_math; 
 sum3 = sum3 + im[i].student_C;
 j++;
 }
 printf(" Average score in English : %0.2f\n",sum1 / j);
 printf(" Math gpa : %0.2f\n",sum2 / j);
 printf("C Language average : %0.2f\n",sum3 / j); 
}

// Statistics of the passing rate of each course and output 
void evsub_ave(information im[])
{
 int i,j = 0,count1 = 0,count2 = 0,count3 = 0;
 
 for(i = 0;i < size;i++)
 {
 if(im[i].student_eng >= 60)
 {
 count1++;
 }
 if(im[i].student_math >= 60)
 {
 count2++;
 }
 if(im[i].student_C >= 60)
 {
 count3++;
 }
 j++;
 }
 printf(" The passing rate of English is: %0.2f\n",count1 * 100.0 / j);
 printf(" The passing rate of mathematics is: %0.2f\n",count2 * 100.0 / j);
 printf("C The language passing rate is: %0.2f\n",count3 * 100.0 / j);
}

// Output the make-up examination list of each subject 
void rebuild(information im[])
{
 int i,flag = 1;
 
 printf(" English make-up examination list: \n");
 for(i = 0;i < size;i++)
 {
 if(im[i].student_eng < 60)
 {
 printf(" Name: %s\t",im[i].student_name);
 printf(" Student number: %d\t",im[i].student_number);
 printf(" English score: %0.2f\n",im[i].student_eng);
 flag = 0;
 }
 }
 if(flag == 1){
 printf(" No make-up! \n");
 }else{
 flag = 1;
 }
 printf(" Math make-up exam list: \n");
 for(i = 0;i < size;i++)
 {
 if(im[i].student_math < 60)
 {
 printf(" Name: %s\t",im[i].student_name);
 printf(" Student number: %d\t",im[i].student_number);
 printf(" Math scores: %0.2f\n",im[i].student_math);
 flag = 0;
 }
 }
 if(flag == 1){
 printf(" No make-up! \n");
 }else{
 flag = 1;
 }
 printf("C Language make-up list: \n");
 for(i = 0;i < size;i++)
 {
 if(im[i].student_C < 60)
 {
 printf(" Name: %s\t",im[i].student_name);
 printf(" Student number: %d\t",im[i].student_number);
 printf("C Language scores: %0.2f\n",im[i].student_C);
 flag = 0;
 } 
 }
 if(flag == 1){
 printf(" No make-up! \n");
 }
}

// Sort the students by their student Numbers ( From small to large )
void num_sort(information im[])
{
 int i,j;
 information stu_temp;
 
 for(i = 0;i < size;i++)
 {
 for(j = 0; j<size-1-i; j++)
 {
 if(im[j].student_number > im[j+1].student_number)
 {
 stu_temp = im[j];
 im[j] = im[j+1];
 im[j+1] = stu_temp;
 }
 }
 }
 printf(" Sorted results: \n");
 for(i = 0;i < size;i++)
 {
 printf("%d\t",im[i].student_number);
 }
}

// Rank the average score of the students ( From big to small )
void ave_sort(information im[])
{
 int i,j;
 float ave[size],ave_temp;
 information stu_temp;
 
 for(i = 0;i < size;i++)
 {
 ave[i] = (im[i].student_eng + im[i].student_math + im[i].student_C)/3;
 }
 for(i = 0;i < size-1;i++)
 {
 for(j = 0; j<size-1-i; j++)
 {
 if(ave[j] < ave[j+1])
 {
 stu_temp = im[j];
 im[j] = im[j+1];
 im[j+1] = stu_temp;
 
 ave_temp = ave[j];
 ave[j] = ave[j+1];
 ave[j+1] = ave_temp;
 }
 }
 }
 printf(" Sorted results: \n");
 for(i = 0;i < size;i++)
 {
 printf("%0.2f\t",ave[i]);
 }
}

int main(void)
{ 
 information student[max];
 int geshu;
 int value = -1; 
 int student_id,index;
 char user[] = "admin\0";
 char key[] = "key\0";
 char user2[10],key2[10];
 printf(" Please enter user name: \n");
 scanf("%s",&user2);
 printf(" Please enter your password: \n");
 scanf("%s",&key2);
 if(strcmp(user,user2) !=0 || strcmp(key,key2) !=0)
 {
 printf(" Username or password error! \n");
 return;
 }
 else
 {
 while(value != 0)// According to the "0" Exit actions  
 { 
 menu(); 
 printf(" Please select the action to perform: \n");
 scanf("%d",&value); 
 switch(value)// According to the value To perform the corresponding operation  
 {
 case 1://1--- Students enter 
 printf(" Please enter the number of student information you want to enter: "); 
 scanf("%d",&geshu); 
 add_student(student, geshu); 
 break;
 case 2://2--- Students insert 
 printf(" Please enter the location of the inserted student: \n");
 scanf("%d",&index);
 st_insert(student,index);
 break;
 case 3://3--- Students query 
 printf(" Please enter the student number of the student to be inquired: ");
 scanf("%d",&student_id);
 check_oneStudent(student,student_id);
 break;
 case 4://4--- Students to delete 
 printf(" Please enter the student number to delete: ");
 scanf("%d",&student_id); 
 del_studentinfor(student,student_id);
 break;
 case 5://5--- Students output 
 check_student(student);
 break;
 case 6://6--- Calculate the average score of each student and output 
 aveGrade(student);
 break;
 case 7://7--- Calculate the average score for each subject and output it  
 ev_grade(student);
 break;
 case 8://8--- Rank the average score of the students 
 ave_sort(student);
 break;
 case 9://9--- Statistics of the passing rate of each course and output 
 evsub_ave(student);
 break;
 case 10://10--- Output the make-up examination list of each subject (including student number, name and score) 
 rebuild(student);
 break;
 case 11://11--- Sort the students by their student Numbers  
 num_sort(student);
 break;
 case 0://0--- exit 
 printf(" Exit successfully! ");
 break;
 default:
 printf(" Enter message error!! "); 
 } /*end of switch*/
 }/*end of while*/
 } 
}

For more information, please refer to the topic "management system development".


Related articles: