-
Problem with Arrays
I declared 4 different arrays. I dont know how to display all the arrays. Can anyone please help me with this? I want to display all 4 arrays like this:
Student 1 2 3 4 5 6 7 Time Status Final
1 0 0 0 0 0 0 0 6.50 B 0
2 5 6 7 8 2 1 3 4 C 0
3 0 0 0 0 0 0 0 7.50 B 0
4 3 4 5 1 2 9 4 12 A 0
Code:
int main()
{
const int NUM_STUDENT = 4;
const int NUM_QUIZ = 7;
int student = 0;
int quiz = 0;
double grade[NUM_STUDENT][NUM_QUIZ] = {{0, 0, 0, 0, 0, 0, 0},
{5, 6, 7, 8, 2, 1, 3},
{0, 0, 0, 0, 0, 0, 0},
{3, 4, 5, 1, 2, 9, 4}};
double time[4] = {9, 10.5, 10.5, 12};
char status[4] = {'B', 'C', 'B', 'A'};
double final [4] = {0, 0, 0, 0};
}
-
You just need a loop or two. Start by outputting the header. Then write the code to output the student number (1, 2, 3 and 4) each on its own line. Make sure you compile and test to verify what you have is working. Then keep doing something else one step at a time. When you get stuck with a specific step, you can ask for more help.
Do you know which type of loop you should use?
-
I know I have to use for loop for that but I don't know how to use for loops to display all arrays.
-
Ah yes, the dreaded forum cross-poster.
Pick one and stick with it. Don't be rude.
-
>> I don't know how to use for loops to display all arrays.
Do you know how to use a for loop to display one array? Do you know how to display one item in one array without a loop? Start with what you know and work from there.