consider an array marks[20][5]which stores the marks obtained by 20 students in 5 subjects
#include <iostream>
using namespace std;
int main()
{
const int N = 20, M = 5;
float marks[N][M];
cout << "Please, enter an array of subjects:\n";
for (int i = 0; i < N; i++)
{
cout << "Please, enter 5 marks for the "<<i+1<<" student:"<<endl;
for (int j = 0; j < M; j++)
{
cout << "Please, enter a mark for the " << j + 1 << " subject: ";
cin >> marks[i][j];
}
}
cout << endl;
cout << "Marks of students:\n";
for (int i = 0; i < N; i++)
{
cout << i+1 << " student ";
for (int j = 0; j < M; j++)
{
cout<<marks[i][j]<<" ";
}
cout << endl;
}
}
Comments
Leave a comment