so im making an else if statement, but when i try to run it i get this [error] 'else' without previous 'if'

//choice1
cout<<"choices"<<endl;
cout<<"A: try to leave an impression B: normal introduction"<<endl;
cin>>choice1;
if (choice1=="A");
{
cout<<"the class was pretty amused"<<endl;
}
else if(choice1=="B");
{
cout<<"there was an awkward silence , i hated it"<<endl;
}

Your biggest mistake is putting the semicolon after the if and else if bracket.

try this

1
2
3
4
5
6
7
8
9
10
char choice1;                                                     //Notice the char.
cout<<"choices"<<endl;
cout<<"A: try to leave an impression	B: normal introduction"<<endl;
cin>>choice1;
if (choice1=='A')                                          //Notice the single apostrophe and no ;
cout<<"the class was pretty amused"<<endl;

else if(choice1=='B')                                   //Notice the single apostrophe and no ;
cout<<"there was an awkward silence , i hated it"<<endl;
Topic archived. No new replies allowed.