Error Cannot Solve

Can someone tell me how to fix these errors! I've tried working on this for a couple hours and I've had no progress at all!

1
2
3
4
5
6
7
8
9
10
11
12
else( operation == 'M' || operation == 'm');
  {
  
	    cout<< "You have selected the operation 'Multiplication'!"<<endl;
		cout<< "Please enter the first number you would like to multiply!"<<endl;
		cin>> var1;
		cout<< " Please enter the second number you would like to multiply!"<<endl;
		cin>> var2;
		answer= var1 * var2;
		cout<< "The answer to your problem is "<< answer<<endl;
		}



The errors that I get are:

error: expected primary expression before else
error: expected ';' before else

Thanks in advance.

You're getting errors on "before else" and you're asking us to debug your code based on the code after else?

Anyway, take a good look at how if-else structures work. Else doesn't take a comparison; it triggers when the 'if' clause returns false. Secondly, the semicolon (';') after the comparison isn't supposed to be there.

It goes like this:

1
2
3
4
5
6
if (statement) {
  // Actions
}
else {
  // Actions
}


No statement after else and no semicolon after statement.
Sorry, never knew that......

But at least you pointed out to me that I had an error before the else.

Thanks
Last edited on
It's actually completely possible that the faults I mentioned are the reason of those errors. Compiler errors aren't always clear/correct on the location of the faults.

However, it makes little sense that you didn't "believe" the error report and decided to post another part of the code.
... I think I'm gonna choose a new compiler... the one I've been using has been quitting on me lately.
Topic archived. No new replies allowed.