Through the study of Student information management system software, c program, how to design and write an application system

Source: Internet
Author: User


C The language regards the computer's input as a file .

So, if you write a string into a file, what is the way? Display to the screen is the default output file, if it is a file on the hard disk, the first to open a file, and then to write in, then you need to tell the program where the file, in what way open (read, write, read and write, add, overwrite, etc.), Then open to give this open file a symbol (pointer variable), indicating that the subsequent reading and writing are for this file, not to the screen, this pointer variable will represent the file itself.


For example, Student information management system, need to keep a student's name, gender, age and other information, then set the variable to save a lot of students of this information is a bit inconvenient. Similar to a register, each page can only write the name, if you want to register other information, but also add a register, can only write gender, if the age of registration, but also add a register, can only write age,..., how inconvenient, but also easy to mess. The solution you must think, how simple, a register this page, at the same time write the name, gender, age is not OK? C Language is also the case, if you define a form, a variable record a lot of information at the same time, so in the management system, it is much more convenient. This is the structure.

structs are defined first, because each program uses a different combination of information, such as student information management system, may be the number, name, gender, age, class combination, so The first line tells the program with a struct, the following is a struct, followed by the Stu is the type of the struct, like an integer in int , this stu is your own name.



If there is no class, our school students in a class, can imagine how chaotic management. We think of a way, the students in accordance with the Professional division to the use of the class, so that the management is more convenient, the Department of the notice, etc., only sent to the monitor on the line, by the monitor down the communication, the class internal change activities, and other classes do not have a relationship, they closed the door to modify it can be. So the program is the same, if all the code is put together, and all the students in the whole school in a class, each other, the program code is short there is no problem, the program code a lot, it will be very difficult to manage. So according to the function, put the different code together, surrounded by braces, and then give the code a name, similar to the name of our class, and then set the parameters, once using this function to pass the actual value, like an addition function, complete two number of the sum, we can write

Myadd (int A, int b)

{

Intc

C=a+b;

return C;

}

Myadd is the name we give this function, in order to use,the function of a and B to receive the number passed by the caller, and then add the received number of two to return, the value of this function after the call is the return value of C, So if we want to count 99+23 equals, just call the function we wrote.

Myadd (99,23), this time the value of the function is 99+23 , if the result is stored in the variable d , you can write

D=myadd (99,23);

With the function, we can organize different functions of the code together, not only their own convenience, and the program is particularly simple and clear, easy to modify, other people write functions we can also directly use.

So our Student information management system form is very simple, a total of three functions

int main ()

{

Inti,sum;

Pagedis ();

Check ();

menu ();

}

The first one is to display the Welcome page, the second is to verify the user name and password, the third is to display the menu, and to perform the appropriate action based on the user's input selection.

There are also some other functions, which are sub- functions called by the menu function, respectively.

This is the approximate form of a structured-speech program.

#include <stdio.h>

void Pagedis ();

void check ();

void menu ();

int main ()

{

Pagedis ();

Check ();

menu ();

}

void Pagedis () {

printf (" I am the module that displays welcome interface, the concrete content also needs to be perfected!") \ n ");

}

void Check () {

printf (" I am the module that verifies the legality of the user, the specific content should be perfected!") \ n ");

}

void menu () {

printf (" I am the module that directs the user to perform each function, the concrete content also needs to be perfected!") \ n ");

}

This is structured programming, putting functions into functions, and the next step is to concentrate and refine the contents of the function.



Student Performance Management System:

#include <stdio.h>


#include <stdlib.h>


#include <string.h>


#define SIZE 3/* Define constant size for later modification */


struct Student/* Defines an array of structures to hold students ' information */


{


int number; /* Study Number */


Char name[20];/* name */


Char xueyuan[20];/* College * *


int cla;/* class */


int score[3];/* Score */


int sum;/* Total Score */


int average;/* Average */


}stu[size];



void menu ();/* Call the Menus function */


void write ();/* Read in Information */


void Save (int x);/* Save Stud.dat File function */


void saveonestudent (int i);/* Save a student's information */


void saveallstudent (int n);/* Save all Student information */


void Inturn (struct student c[]);/* function to sort students ' information by student number */


void Save2 ();/* Stores sorted information in the Student.dat file */


int addstudent (int n);/* Increase student information */


void inputonestudent (int i);/* Enter a classmate's information */


int delstudent (int n);/* Delete Student information */


void modifystudent (int n);/* Modify Student Information */


void outputonestudent (int i);/* Query A student's information */


void Searchmenu (int n);/* Query Student information operation */


void Searchnumber (int n);/* Query Student information by study number */


void Searchname (int n); * * Query Student information by name */


void Searchxueyuan (int n); * * Check student information at your college * *


void Searchcla (int n); * * Check student information in your class * *


void Tongji ();/* Student Information statistics Operation */


void Tongji2 ();/* Statistical failure rate Operation */


void ZFSC ();/* Total sorting operation */


void Avecz (); */* According to the average number of statisticians operation */


void Avecz (); */* According to the average number of statisticians operation */


void search ();/* Find top performance Action */


void Tongji2 ();/* Statistical failure rate Operation */


void read (); * * Read Student.dat file file information for secondary students * *



/* Main function ************************************************************************************/


void Main ()


{


int n=size;


int choice;/* User Selection variable */


printf ("*******************************************************************************\n");


printf ("* *\n");


printf ("* Hwadee & Student Performance Document management & Hwadee *\n");


printf ("* *\n");


printf ("*******************************************************************************\n\n\n");


printf ("****************************** Welcome to use *********************************");


while (1)


{


Menu ()//* Call the function to form the operator interface */


printf ("Please select:");


scanf ("%d", &choice);


if (choice==0)


{


printf ("\t\t\t\t Thank you for using!!!");


Break


}


Switch (choice)/* Multi-Select to implement different functions */


{


Case 1:


Write ();


Inturn (Stu);


Save (SIZE);


Break


Case 2:


Addstudent (n);


Break


Case 3:


Delstudent (n);


Break


Case 4:


Modifystudent (n);


Break


Case 5:


Searchmenu (n);


Break


Case 6:


Tongji ();


Break


Case 0:


printf ("\ n Thank you for using! Goodbye!\n");


Default


printf ("\ n key Error! Please re-select!\n");


}/* End switch*/


}/* End while*/


}


Partial program List


/* Menu Function *************************************************************************************/


void menu ()


{


printf ("************ Please enter the desired action ***********\n");/* Select the function menu */


printf ("*************************************\n");


printf ("1. Writing and sequencing of student grades \ n");


printf ("2. adding student information \ n");


printf ("3. Delete Student information \ n");


printf ("4. Modify student information \ n");


printf ("5. query student information \ n");


printf ("6. Student performance statistics operation \ n");


printf ("0. Exit system \ n");


printf ("**************************************\n");


}



/* Write function *************************************************************************************/


void Write ()


{


int i;/* Count Variable */


for (i=0;i<size;i++)


{


printf ("Study No.:");


scanf ("%d", &stu[i].number);


printf ("Name:");


scanf ("%s", &stu[i].number);


printf ("College:");


scanf ("%s", &stu[i].xueyuan);


printf ("Class:");


scanf ("%d", &STU[I].CLA);


printf ("High number:");


scanf ("%d", &stu[i].score[0]);


printf ("English:");


scanf ("%d", &stu[i].score[1]);


printf ("C language:");


scanf ("%d", &stu[i].score[2]);


Stu[i].sum= (stu[i].score[0]+stu[i].score[1]+stu[i].score[2]);/* Calculation of the total scores */


printf ("Total:%d", stu[i].sum);


Stu[i].average= (stu[i].score[0]+stu[i].score[1]+stu[i].score[2])/3;/* calculate average score */


printf ("Average score:%d\n", stu[i].average);


}


}


Through the study of Student information management system software, c program, how to design and write an application system

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.