English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

with their names as well ( not only the marks also with names in acsending order)?

there can be minimum of 1 student or maximum 40 students ina class.it is mandatory for all students to take 4 subjacts every semester namely mathematics, science,history and english for the final exam students can get marks between 0 and 100.
a c++ program to accept number of students in the cladss, all student's names and final exam marks foe each subject.Print the names of students,mark foreach subject,and aggregate in acsending order of the aggregrate marksfor the final exam.

2007-09-05 17:59:05 · 3 answers · asked by RAVINDU 2 in Computers & Internet Programming & Design

3 answers

Hi,
To get the desired result, u declare a structure like the following:
struct student
{
char name[20];
int math;
int science;
int history;
int english;
int total;
}stu;

Now u can use dynamic array (means Linked List).
U start filling each student details into this structure and Total marks in total element of the above structure.
U design ur linked list in such a fashion that each node is added in ascending order of Total Marks of each student.
The moment u r done entering marks, u can print ur linked list from begining to end.
The result would be in ascending order of Total Marks, because ur linked list is already sorted.
u can put the condition for min/max nos. of students like this
while(studentnos<=40)
scanf("%s",stu.name);
scanf("%d",stu.math);
scanf("%d",stu.science);
scanf("%d",stu.history);
scanf("%d",stu.english);
stu..total=stu.math+stu.science+stu.history+stu.english;
addtoLinkedList(struct student **); //a function for adding each student detail
studentnos++;
}

the moment u come out of this loop, ur list will be in sorted order of total marks. just print it.

2007-09-05 21:50:45 · answer #1 · answered by iqbal 4 · 0 0

sure as long as you on the instantaneous are actually not attempting to erect a flat packed greenhouse, tried that very final week and function self belief me that tempting bottle of pink wine did now not make the training any much less complicated to appreciate

2016-10-18 02:35:36 · answer #2 · answered by Anonymous · 0 0

better use class

student
with properties
like name marks total average etc

and methods to input them , manipulate and display them

2007-09-05 18:11:09 · answer #3 · answered by i_am_the_next_best_one 5 · 0 0

fedest.com, questions and answers