C exercises and solutions: C structure


C structure: Student Record

Write a C program to keep records and perform statistical analysis for a class of 20 students. The information of each student contains ID, Name, Sex, quizzes Scores (2 quizzes per semester), mid-term score, final score, and total score.
The program will prompt the user to choose the operation of records from a menu as shown below:
============================================

                                             Menu


============================================
1. Add student records

2. Delete student records

3. Update student records

4. View all student records

5. Calculate an average of a selected student’s scores

6. Show student who gets the max total score

7. Show student who gets the min total score

8. Find student by ID

9. Sort records by total scores


Enter your choice:1
 
Note: All students records store in an array of structures

Solution:


To keep this solution simple and easy to follow, we divide this solution in to different steps:
Step 1: Declaring a structure called student to store the records. The structure student contains nine members:
-stnumber(string) to store the student' id
-stname(array of characters) to store the student's name

-sex(char) to store the student's sex

-quiz1(float) to store the first quiz score

-quiz2(float) to store the second quiz score

-assignment(float) to store the assignment score

-midterm(float) to store the mid-term score

-final(float) to store the final score

-total(float) to store the total score
 
typedef struct
{

string stnumber;
char stname[20];
char sex;
float quiz1;
float quiz2;
float assignment;
float midterm;
float final;
float total;

}student;



Comments

imran comment

 imran

39) Write a C program to keep records of students. The information of each student contains ID, Name, gender, quizzes Scores (2 quizzes per semester), mid-term score, final score, and total score. (Passing structure to a function by reference). i want this program in c


2017-04-23
Bea Faye comment

 Bea Faye

how to make it a databased ? it is for my project . hope you could help me. thanks.


2016-03-18



This website intents to provide free and high quality tutorials, examples, exercises and solutions, questions and answers of programming and scripting languages:
C, C++, C#, Java, VB.NET, Python, VBA,PHP & Mysql, SQL, JSP, ASP.NET,HTML, CSS, JQuery, JavaScript and other applications such as MS Excel, MS Access, and MS Word. However, we don't guarantee all things of the web are accurate. If you find any error, please report it then we will take actions to correct it as soon as possible.