I'm having trouble writing a program. I have to determine the name of student
who scores the highest marks for each module and the highest in the average
score of 5 modules. Hence display them in a table form where 1st column is the
modules and the 2nd column is the student's names.
Display the ranking of the average scores of the students in the table format
where 1st column is the rank number, the 2nd column is the names of students and
the 3rd column is the average scores. I need to use arrays and pointer to solve
this problem.

the originial table is as follows:

Mechanical Maths Programming Electronics Automation
John 78 61 52 85 79
Sam 67 49 75 71 85
Clinton 82 70 68 50 65
Harry 55 66 79 89 77
Tom 73 75 81 74 69

*much help is appreciated*

This is how far i've managed to write the program without using pointers. I have difficulty in using pointers. Hope someone would help me out.

#include <stdio.h>
void sort( int [], int [], int );
int numbers[25] = { 78, 61, 52, 85, 79, 67, 49, 75, 71, 85, 82, 70, 68, 50, 65, 55, 66, 79, 89, 77, 73, 75, 81, 74, 69};
int arrange[6] = {0, 1, 2, 3, 4, 5};
char names[5][30] = {"John", "Sam", "Clinton", "Harry", "Tom"};
int loop;
printf("Before the sort the array was \n\tMechanical Design Mathematics Programming Electronics Automation\n");
printf("John\t\t78\t\t61\t 52\t\t 85\t\t 79\n");
printf("Sam\t\t67\t\t49\t 75\t\t 71\t\t 85\n");
printf("Clinton\t\t82\t\t70\t 68\t\t 50\t\t 65\n");
printf("Harry\t\t55\t\t66\t 79\t\t 89\t\t 77\n");
printf("Tom\t\t73\t\t75\t 81\t\t 74\t\t 69\n");
sort( numbers, arrange, 3 );
printf("\nAfter the sort the array was\n");
printf("Modules\t\t\tName\t\t\Rank\tName\t\tAverage Score\n");
printf("Mechanical Design\t%s\t\t1\t%s\t\t74.4",names[2],names[4]);
return 0;
void sort( int a[], int b[], int elements )
int i, j, temp, temp_b;
i = 0;
while( i < (elements - 1) ) {
j = i + 1;
while( j < elements ) { 
if( a[i] > a[j] ) {
temp = a[i];
temp_b = b[i];
a[i] = a[j ];
b[i] = b[j];
a[j] = temp;
b[j] = temp_b;

First, when you post code to this board please enclose it in code tags. You can get instructions how to use them by reading the water marks in the text entry box for the board or by reading the sticky posts at the top of the board.

Then, from the code you posted it looks like you are probably going to try to do this with a series of parallel arrays as opposed to using a multidimensional array. Is that correct? It's more work to it that way but if you don't know how to use multidimensional arrays, so be it.

Also, will you know how the maximum number of students and the maximum number of grades there will be before running the program or will you need to figure it out by reading a file or something?

random rep++ from Salem
This article has been dead for over six months. Start a new discussion instead.