Thursday, July 30, 2009

How can use class or structure and dynamic arrays for following problem and how to sort the aggregrate marks w

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.

How can use class or structure and dynamic arrays for following problem and how to sort the aggregrate marks w
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%26lt;=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.hi...


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.
Reply:better use class





student


with properties


like name marks total average etc





and methods to input them , manipulate and display them


No comments:

Post a Comment