The studentType structure contains five components which are name and programme of type string, id of type int, mark of type double and totalmarks of type double. Thr marks component is of three elements.
Write a program to define the studentType structure. Since there are 20 students in the class, the program must also declare an array varialble of size 20 named student. The student array is of type studentType structure. The program retrieve data of each student from the user and finds the student whose totalmarks is the highest among the 20 students. The program should also be able to ensure that the record of the student with the highest totalmarks is the first element in the student array. If this is not the case, the program must swap this record’s position with the record of the first element in the array. Finally the program should also be able to print the record of all the students. The program must have the following functions:
Function name
getInput --------- this function retrives records of one student at a time from the user. It receives input for name, programe, id and the values of marks from the user. The function determines the totalmark value by adding the three values of marks. The function returns record of one student at a time.
findMax---------- this function receives the record of all students as parameter and finds the student with the highest totalmarks.This function returns the index number of the array element whose totalmarks value is the highest.
swapRecord------ this function receives two parameters i.e record of the first elements in student array and record of the student whose totalmarks is the highest. The program swaps the positions of the two records and return them to main function
printRecord-------- this function prints the record of all students by following the format is this example:
Name Programme ID mark 1 mark2 mark3 TOTAL
Mike BIS 1111 10.0 10.0 19.8 39.8
Jamie T. ICT 2222 9.9 10.0 19.0 38.9
Write a program to define the studentType structure. Since there are 20 students in the class, the program must also declare an array varialble of size 20 named student. The student array is of type studentType structure. The program retrieve data of each student from the user and finds the student whose totalmarks is the highest among the 20 students. The program should also be able to ensure that the record of the student with the highest totalmarks is the first element in the student array. If this is not the case, the program must swap this record’s position with the record of the first element in the array. Finally the program should also be able to print the record of all the students. The program must have the following functions:
Function name
getInput --------- this function retrives records of one student at a time from the user. It receives input for name, programe, id and the values of marks from the user. The function determines the totalmark value by adding the three values of marks. The function returns record of one student at a time.
findMax---------- this function receives the record of all students as parameter and finds the student with the highest totalmarks.This function returns the index number of the array element whose totalmarks value is the highest.
swapRecord------ this function receives two parameters i.e record of the first elements in student array and record of the student whose totalmarks is the highest. The program swaps the positions of the two records and return them to main function
printRecord-------- this function prints the record of all students by following the format is this example:
Name Programme ID mark 1 mark2 mark3 TOTAL
Mike BIS 1111 10.0 10.0 19.8 39.8
Jamie T. ICT 2222 9.9 10.0 19.0 38.9