I don't know if I'm just confusing myself or what... This is the problem that I am supposed to do:
1 2 3 4
Write a program that uses a two-dimensional array of characters to hold the five stu-
dent names, a single-dimensional array of five characters to hold the five student's let-
ter grades, and five single-dimensional arrays of four doubles to hold each student's
set of test scores.
The program I wrote sort of worked but since it's always good to get the input of others, I want to make sure I am understanding everything clearly. So, I'll do a sample model for the problem above:
1 2 3 4 5 6 7 8 9 10 11
constint NUM_STUDENTS = 5, //number of students
STRING_SIZE = 10; //maximum size of each string
GRADES = 4; //number of test scores for each student
char names[NUM_STUDENTS][STRING_SIZE]; //The names of five students with maximum
//of 10 characters for each name entered
char letter_grade[NUM_STUDENTS]; //the letter grades for the five students
double test1[GRADES], //
test2[GRADES], //
test3[GRADES], // the test grades for the five students. not sure if this
test4[GRADES], // part is correct.
test5[GRADES]; //
The program should allow the user to enter each student's name and his or her four
test scores. It should then calculate and display each student's average test score and a
letter grade based on the average.
The only part that is giving me trouble is entering the student's names. Would I use a nested for loop or something?
Actually, somewhere in between. Using getline is probably the right approach, but you need to dereference names once (not twice). And a single for loop should work fine.