In addition to Solution 1 and following up on Richard's comments.
You need to store the Percentage that you have calculated. You
could just add another column to the array but to do that would be ignoring everything that C++ is capable of.
Create a class to store each student and the marks for each subject - and move that function Percent into the class as a method on the members of the class. You have some choices on how you define the class e.g.
class student {
public:
float studentID;
float Subj1;
float Subj2;
float Average;
}
or
class student {
public:
int studentID;
float marks[6];
float Average;
}
You might decide to not have Average as a property of the class but you are going to want to use that value a few times, so consider: do you really want to calculate it each time? All of these things are up to you and these decisions are what you will be graded on for your assignment
Once you have your class, you can declare an array of that class. Or a list.
Then, your input loop should create a new object from the class each time and assign it an id (hint: your loop counter
i
will do as the id).
You can have an inner loop that captures input from the user for each of the 6 subjects.
Once you have all the marks for a single student, calculate the Percentage by calling the method on that object.
Once you have done that for all students, sum the average across all students and divide by the number of students to get the class average. Store that in a variable.
Finally sort the array into descending order. The index of the sorted array is that student's "position" in the class