Lab 1: Develop an application for Student Status Management

Source: Internet
Author: User

Lab Purpose

In the C language environment (Turbo C or Vc), write a simple application to manage student status.

Through this experiment, students can skillfully write basic applications in the C language environment.

Lab Significance

Through this experiment, students can further understand the use of structures and arrays in the C language and be familiar with basic input and output methods.

Lab background

There are 30 students in a class. The materials for each student include student ID, name, gender, nationality, grade, Major, class, course, etc, you can enter the information of each student to display and modify the information of each student. At the beginning of the program running, you can choose to enter, modify, or display.

Lab steps and requirements

1. design the storage structure of student data

2. Create initial data for 10 students

3. Modify the Professional and Local Information of two students

4. Delete all information of two students

5. display all information of existing students

6. Submit the source program list and program comments.

7. Submit the program usage method and program user interface

8. Hands-on demonstration of experiment results

Lab hours

3 hours

# Include <iostream> # include <cstdio> # include <cstring> using namespace STD; struct Stu // create a struct {int num; char name [20]; char sex; char adress [100]; char grade [100]; char professional [100]; char classes [100]; char course [100];} STU [1000]; int I = 0; void input () // execute the input Member Data {int N, T; printf ("Enter the number of people who want to create the data, each item occupies one row \ n "); scanf (" % d ", & N); t = I; for (; I <t + N; I ++) {printf ("Enter student ID \ n"); scanf ("% d", & STU [I]. num); printf ("Enter the Student name \ N "); scanf (" % s ", STU [I]. name); printf ("input Student gender \ n"); getchar (); scanf ("% C", & STU [I]. sex); printf ("input student nationality \ n"); scanf ("% s", STU [I]. adress); printf ("input student grade \ n"); scanf ("% s", STU [I]. grade); printf ("input student Major \ n"); scanf ("% s", STU [I]. professional); printf ("input student class \ n"); scanf ("% s", STU [I]. classes); printf ("input student course \ n"); scanf ("% s", STU [I]. course) ;}} void modify () // modify {int n, m, J; char str1 [100]; printf ("Enter the number of people to modify \ n "); Scanf ("% d", & N); While (n --) {printf ("Enter the student ID to be modified \ n"); scanf ("% d ", & M); For (j = 0; j <= I; j ++) {If (STU [J]. num = m) // determine the student (s) to be repaired {printf ("delete input Yes, other input NO \ n"); scanf ("% s", str1 ); if (! Strcmp (str1, "yes") // whether to delete {While (j <I) {STU [J] = STU [J + 1]; j ++ ;} I --; break;} printf ("Modify end input Yes \ n"); printf ("enter the information to be modified num, name, classes, course, grade, professional, sex \ n "); scanf (" % s ", str1); While (strcmp (str1," yes ") // determine which information to modify {If (! Strcmp (str1, "num") {scanf ("% d", & STU [J]. Num);} else if (! Strcmp (str1, "name") {scanf ("% s", STU [J]. Name);} else if (! Strcmp (str1, "classes") {scanf ("% s", STU [J]. classes);} else if (! Strcmp (str1, "Course") {scanf ("% s", STU [J]. Course);} else if (! Strcmp (str1, "Grade") {scanf ("% s", STU [J]. grade);} else if (! Strcmp (str1, "professional") {scanf ("% s", STU [J]. Professional);} else if (! Strcmp (str1, "sex") {scanf ("% C", & STU [J]. sex);} printf ("enter the information num, name, classes, course, grade, professional, sex \ n "); printf ("Modify end input Yes \ n"); scanf ("% s", str1) ;}}} void show () {Int J; for (j = 0; j <I; j ++) // output all member information {printf ("% d % S % C % S % s \ n", STU [J]. num, STU [J]. name, STU [J]. sex, STU [J]. adress, STU [J]. grade, STU [J]. professional, STU [J]. classes, STU [J]. course) ;}} int main () {char STR [100]; printf ("select Select input, modify, show \ n "); While (scanf (" % s ", STR )! = EOF) {If (! Strcmp ("input", STR) // determines which operation is performed {input ();} else if (! Strcmp ("modify", STR) {modify ();} else if (! Strcmp ("show", STR) {Show ();} printf ("Select Operation input, modify, show \ n");} return 0 ;}

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.