I am new. Please excuse me.
When compiling the following code that is entirely ‘if’ statements, the final "else" statement does not work. I receive the error message as mentioned in the title. If I change the final "else" to an "else if" the code will run. This makes no sense to me as I was told that the final statement should just be "else". Thanks for any help.
#include <iostream>
using namespace std;
int main() {
int menu, number1, number2;
double sum;
cout << "1: Addition\n2: Division\n\n";
cin >> menu;
if(menu == 1){ //Addition
cout << "gimme a num: ";
cin >> number1;
cout << "gib another: ";
cin >> number2;
sum = number1 + number2;
cout << sum;
}else(menu == 2){ //division !THIS IS THE LINE IN QUESTION!
cout << "gimme a num: ";
cin >> number1;
cout << "gib another: ";
cin >> number2;
sum = number1 / number2;
cout << sum;
}
return 0;
}
>Solution :
Remove "(menu == 4)" after that last else.