I'm writing a program to demonstrate the use of structures. here it is:
#include<iostream>
using namespace std;
struct courseRecord {
int myTests[10][5];
char name[20];
char day[20];
int courseid;
};
struct courseRecord college[100];
int main ()
{
int a,b,c;
cout << "\n Enter the course data: \n" << "------------------";
cout << "\n How many courses?";
cin>> c;
for (a = 1;a <= c; a++)
{
do {
cout << "\n What is the name of course " << a << " ? ";
cin >> college[a].name;
cout << "\n What is the id number for this course?";
cin >> college[a].courseid;
cout << "\n What day does this course meet?";
cin >> college[a].day;
cout << "\n How many tests have you taken in this course?";
cin >> b;
for ( int test=1; test<= b ;test++)
{
cout<< "\n Grade on test "<<test<<"?";
cin>> college[a].myTests[a][test];
}
}
while (a <= c);
}
cout<< "\n\n Enter the ID for the course you want to view: ";
cin>>a;
cout<< "\n Course: " << college[a].name;
cout<< "\n Day of course: " << college[a].day;
cout<< "\n Your test results: ";
for (int x = 1; x <= 5; x++){
cout<< college[a].myTests[a][x];
}
cout<< "\n\n";
system("pause");
return 0;
}
the issue here is that it keeps asking for the information in course 1 over and over again without moving to the part where the name day and course test results are printed. how would i go about fixing this?
for (a = 1; a <= c; a++)
{
cout << "\n What is the name of course " << a << " ? ";
cin >> college[a].name;
cout << "\n What is the id number for this course?";
cin >> college[a].courseid;
cout << "\n What day does this course meet?";
cin >> college[a].day;
cout << "\n How many tests have you taken in this course?";
cin >> b;
for ( int test=1; test<= b ; test++)
{
cout<< "\n Grade on test "<<test<<"?";
cin>> college[a].myTests[a][test];
}
}