Hi guys,
i am trying to write codes using multidimensional arrays, the program should output the names and grades of 10 students writing 6 exams, i have included the little that i know
#include <iostream>
using namespace std;
int main()
{
char chris[3][4] = {{'A', 'B', 'C', 'D'},
{'B', 'C', 'D', 'A'},
{'C', 'D', 'A', 'B'}};
for ( int Exams = 0; Exams < ; ++Exams )
{
for ( int Student = 0; Student < 4; ++Student )
{
cout << chris [Student][Exams] << " ";
}
cout << endl;
}
return EXIT_SUCCESS;
}
pls anybody,guide me on how to insert names and and scores and grades. thankx
First of all, please use the "Source code" button for pasting the code (
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
int main()
{
char chris[3][4] = {{'A', 'B', 'C', 'D'},
{'B', 'C', 'D', 'A'},
{'C', 'D', 'A', 'B'}};
for ( int Exams = 0; Exams < ; ++Exams )
{
for ( int Student = 0; Student < 4; ++Student )
{
cout << chris [Student][Exams] << " ";
}
cout << endl;
}
return EXIT_SUCCESS;
}
It looks more clear :)
I'm not sure if I understand everything clear.
From the first paragraph I conclude you need matrix like this:
x,x,x,x,x,x,x
x,x,x,x,x,x,x
x,x,x,x,x,x,x
x,x,x,x,x,x,x
x,x,x,x,x,x,x
x,x,x,x,x,x,x
x,x,x,x,x,x,x
x,x,x,x,x,x,x
x,x,x,x,x,x,x
x,x,x,x,x,x,x
So in first column you will hold name, and in the second first exam degree, second, third etc.
But in code you have array named "Chris" with four columns and 3 rows...and I don't get it. Do you want 10 two-dimensional arrays with name and score from test?
Speaking about your last question you can insert name by using cin :)