valid types int[int] for array subscripts

When I run this program I face this problem(topic) any quick advice>??

Thanks







#include<iostream>
#include<cstdio>

#define max 10
#define maxrow 4

using namespace std;
enum first{CIS_320=1, other_classes , Quit}; //All the funtino prototype are defined in this area
void cis_32(); // most of the funtions are defined as VIOD because we just needed to
first menu(); // cout the fees and then call the GRANT TOTAL funtion to
int student_ID,midterm_grade;
void bigswitch(first);


int main(){
//int a[10][4]; // this is the main funtion
//it was hard at first to come up with the
first selection; //write do/while function
//do{
selection=menu();
bigswitch(selection);
//}while(selection!=3);
system("pause");
}

first menu(){ // this is the menu and the example 2.6a helped alot to
bool valid; // figure out this part
first selection;
cout<<"\n\n\t\t\tPlease Select From The Menu Below:";
cout<<"\t\n1) CIS 302";
cout<<"\t\n2) Other classes";
cout<<"\t\n3) Quit"<<endl;
cin>>(int &)selection;
return (selection);
}

void bigswitch(first selection){ // this is the main part of the program
int student_ID,midterm_grade; // the big switch statemnte
// There has been a lot of time that I spent
// for this switch stament and it will do the core job of the
//funtion
switch (selection){ //it consist of 4 cases that they are
case CIS_320: //doing different task themselves
/*do{
cout<<"Please input your student ID<0-100>:";
cin>> student_ID;
cout<<"PLease input the midterm grade"<<endl;
cin>> midterm_grade;
}while(student_ID<0);
*/
cis_32();
break;
case other_classes:

break;

case Quit:
cout<<"thank you";
}
}


void cis_32(){
int midterm_grade,midterm;
int a[10][4];
int id;
bool valid=false;
static int i;
i+=1;



do{
printf("Please Enter student id");
cin>>id;
if (id >=1 && id<=100) {
valid=true;


}

else
valid= false;
for (int a=0; a<i-1; a++){
if (a[i-1][0]==id){
valid=false;
cout<<"Duplicate id , try again";
break;
}else
valid=true;
}
}while(valid==false);
a[i-1][0]=id;
do{
cout<<"Enter the midterm grade";
cin>>midterm_grade;
if (midterm_grade < 0 || midterm_grade>100)
valid=false;
}while(valid==false);
a[i-1][1]=midterm_grade;
do{
cout<<"Enter the final exam grade:";
cin>>final_exam;
if (final_exam<0 || final_exam>100)
valid=false
}while(valid==false);

}

Post the code using "<>" tags from the format menu, it makes easier for us to read the code posted.

You have said you face "This problem", can you post any errors/problems that you are getting.

One error I can catch is
1
2
for (int a=0; a<i-1; a++){
if (a[i-1][0]==id){
you are declaring a as an int in the loop and accessing as an array

Have a look at http://www.cplusplus.com/doc/tutorial/arrays/
Last edited on
Thank you very much..... The problem is " valid types int[int] for array subscripts " which is from the line 80 .


I appreciate your help.
Topic archived. No new replies allowed.