Showing results for 
Search instead for 
Did you mean: 

Students Grade Ranking




I've been working on this project where I list name and exam scores on the input and display name, exam average, grade and rank in class on the output. On the output, I've got name, exam average, and grade but I am struggling with the ranking. Please help.

0 Kudos
Message 1 of 4

What exactly do you mean by ranking?  Highest grade to lowest grade?  You should have the students as an array, you can sort that array based on the final grade.


Also, double check your grades.  According to your case structures, a D is higher than a C.

0 Kudos
Message 2 of 4

Here's a hint -- when you see identical copies of code and names like "Student 1", "Student 2" , etc., you should think "Hey, maybe I can create an array of identical things and run it through a For loop and to exactly the same thing to each of them".


So what does "Rank" mean?  Suppose I have an Array of Students, and each element of this Array had an "Overall Score".  How would you "rank" them?  Suppose you had only the scores.  How would you rank the scores?  Can you think of an Array operation that ranks things?


Bob Schor

0 Kudos
Message 3 of 4


If I get it right, There's no relation between "Student Input", "Student Input 2", and "Student Input 3"?
You're trying to put students in the same array in ranks based on the overall score like this?


Student Rank.pngimage.png

If you don't mind changing the order of the controls in your cluster, try putting the Overall as the first control (including the constant in your code, and you should use typedef anyway for that kind of application). Then use sort 1D array, it will sort your array based on the value of the first control in the clusters (Overall). Add Reverse 1D array if you want them sorted descending.


Extra note on how you apply the "For Loop". With auto-indexing, the for loop will iterate for the lowest number of array elements. So if you have 5 students in Class A and only 4 students in Class B, the remaining 1 student in Class A will be discriminated and ignored....

0 Kudos
Message 4 of 4