Ok. Firstly I'm going to say that I appreciate that learning programming is hard. So stick at it!!
Secondly, both C and C++ are both case sensitive, so if isn't the same as If, nor is else the same as Else. It's only the lower case versions which should work (it's likely that they're typedeffec of defined somewhere, but ... )
The best way to do this is to do something like:
Code:
char option;
int firstnum, secondnum, answer;
cout<< "Enter your first number: ";
cin >> firstnum;
cout<< "Enter your second number: ";
cin >> secondnum;
cout<< "Do you want to (m)ultiply, (d)ivide, (s)ubtract or (a)dd those two numbers?";
cin >> option;
if ( option == 'm' )
{
// Do multiplication stuff here
}
else if ( option == 'd' )
{
// do division stuff here
}
else if ( option == 's' )
{
// do subtraction
}
else if ( option == 'a' )
{
// do addition stuff
}
else
{
cout<< "That option is not available here";
}
Now. Look at that for and see if you can see why it doesn't work as you would like
In your code you made characters called add, subtract etc. These aren't initialised in your code (not given initial values), so saying if something == something else will have indefined effects. You could have said:
Code:
char add='a';
char subtract = 's';
char multiply = 'm';
char divide = 'd';
and then added a
Code:
if ( option == add )
{
[..]
}
thing, but there's no need.