I am having trouble with finding the problem with program. It compiles but produces no output. If you have any ideas PLEASE let me know.
Here is the C code:
/* inputs data from file and calculates high, low, and avg score
Written by: Joshua Kenney
Date: 3.5.02
*/
#include <stdio.h>
#define MAX_COLS 6
#define MAX_ROWS 6
void getScores(int table[][MAX_COLS]);
void calculateScores(int table[][MAX_COLS], int columnAvg MAX_COLS]);
void printScores(int table[][MAX_COLS], int columnAvg[MAX_COLS]);
int main(void)
{
/* local variables */
int table[MAX_ROWS][MAX_COLS];
int columnAvg[MAX_COLS] = {0};
getScores(table);
calculateScores(table, columnAvg);
printScores(table, columnAvg);
return 0;
}
/*getScores
input scores from file and put them in two-dimensional array */
void getScores(int table[MAX_ROWS][MAX_COLS])
{
FILE *scores;
int row;
int col;
scores = fopen("scores.DAT", "r");
if (!scores)
{
printf("Could not open input file\a\n");
}
else
{
for (row = 0; row < MAX_ROWS; row++)
for(col = 0; MAX_COLS; col++)
{
fscanf(scores,"%d", table[row][col]);
}
}
fclose(scores);
return;
}
/*calculateScores
sort and calculate the high, low, and avg score */
void calculateScores(int table[][MAX_COLS], int columnAvg[MAX_COLS])
{
int row;
int col;
for (col = 0; col < MAX_COLS; col++)
{
for (row = 0; row < MAX_ROWS; row++)
columnAvg[col] += table [row][col];
columnAvg[col] /= MAX_ROWS;
}
}
/*printScores
print the table of scores */
void printScores(int table[][MAX_COLS], int columnAvg[MAX_COLS])
{
int row;
int col;
printf("Student/t");
for (row = 0; row < MAX_ROWS; row++)
{
printf("Quiz%d/t", row);
}
for (row = 0; row < MAX_ROWS; row++);
{
for (col = 0; col < MAX_COLS; col++);
printf("%6d", table[row][col]);
}
printf("----------------------------\n");
for(col = 0; col < MAX_COLS; col++)
printf("%6.2f", columnAvg[col]);
return;
}
And here is the .DAT file:
1234 52 7 100 78 34
2134 90 36 90 77 30
3124 100 45 20 90 70