#include <stdio.h>
#include <stdlib.h>
#define STUDENTS 5 // row
#define QUIZZES 7 // column
main(){
int qScores[STUDENTS][QUIZZES] = {
{ 88, 77, 54, 65, 77, 98, 65 },
{ 56, 86, 97, 50, 75, 100, 74 },
{ 60, 89, 58, 86, 90, 60, 79 },
{ 44, 76, 90, 95, 95, 95, 97 },
{ 65, 86, 88, 89, 51, 92, 75 }
};
int studentTotal = 0, quizTotal = 0, row, col;
int topStudent = -1, low = -1, high = 100; // <- intialized the high and low
double studentAverage, highestAverage = 0,lowestAverage = 0, quizAverage;
for( row = 0; row < STUDENTS; row++ ){
studentTotal = 0;
for( col = 0; col < QUIZZES; col++ ){
studentTotal += qScores[row][col];
}
studentAverage = (double) studentTotal / QUIZZES;
printf("Student %i has an average of %.2lf\n\n", row, studentAverage);
if( studentAverage > highestAverage){
highestAverage = studentAverage;
topStudent = row;
}
}
for( col = 0; col < QUIZZES; col++ ){
quizTotal = 0;
for( row = 0; row < STUDENTS; row++ ){
quizTotal += qScores[row][col];
}
quizAverage = (double) quizTotal / STUDENTS;
printf("Quiz %i has an average of %.2lf\n\n", col, quizAverage);
}
printf("Student %i has the highest average with a score of %.2lf\n\n\n", topStudent, highestAverage);
printf("Quiz Grades Range\n");
printf("-----------------\n");
for( col = 0; col < QUIZZES; col++ ){
if(/* Need condition here i think*/){
}
for( row = 0; row < STUDENTS; row++ ){
if(/*Need condition here*/){
}
// Do both if statements go here? Where do I put the high and low?
}
}
printf("Quiz %i: %i - %i\n", col, low, high);
system("pause");
}
This post has been edited by sf18: 17 February 2010 - 04:42 PM

New Topic/Question
Reply




MultiQuote


|