| | |
Hi i'm having trouble with writing a program
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Feb 2007
Posts: 1
Reputation:
Solved Threads: 0
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.
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.
c Syntax (Toggle Plain Text)
#include <stdio.h> void sort( int [], int [], int ); main() { 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; clrscr(); 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("=============================================================================\n"); printf("Mechanical Design\t%s\t\t1\t%s\t\t74.4",names[2],names[4]); printf("\nMaths\t\t\t%s\t\t2\t%s\t\t73.2",names[4],names[3]); printf("\nProgramming\t\t%s\t\t3\t%s\t\t71",names[4],names[0]); printf("\nElectronics\t\t%s\t\t4\t%s\t\t69.4",names[3],names[1]); printf("\nAutomation\t\t%s\t\t5\t%s\t\t67",names[1],names[2]); printf("\nAverage\t\t\t%s",names[4]); getch(); 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; } j++; } i++; } }
Last edited by WaltP; Feb 1st, 2007 at 1:23 pm. Reason: Code tags -- didn't you notice the words on the background you were typing on??? And format your code. It can't be read.
•
•
Join Date: Jul 2005
Posts: 1,753
Reputation:
Solved Threads: 283
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?
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?
![]() |
Similar Threads
- writing a a program in machine code (Assembly)
- Help with Java program writing (Java)
- Linux Shell Script needs help writing program (Shell Scripting)
- Need help writing a program (C++)
- Need help writing a program to classify a poker hand (Java)
- Writing a program that uses a Character Queue (C++)
Other Threads in the C Forum
- Previous Thread: How to connect Database in C????
- Next Thread: Order of precedence
| Thread Tools | Search this Thread |
Tag cloud for C
#include ansi array arrays asterisks binarysearch calculate centimeter changingto char command convert copyimagefile cprogramme creafecopyofanytypeoffileinc database directory dynamic fflush file fork forloop framework functions getlasterror givemetehcodez grade graphics hacking hardware histogram homework inches include incrementoperators input iso kernel km lazy linked linkedlist linux linuxsegmentationfault list lists locate logical_drives looping loopinsideloop. lowest match matrix microsoft motherboard multi mysql number opendocumentformat opensource owf pattern pdf performance pointer posix problem probleminc process program programming radix recursion recv research reversing scanf scripting segmentationfault sequential shape socket socketprograming spoonfeeding standard string strings structures student systemcall testing threads turboc unix user variable voidmain() wab windows.h windowsapi






