Hi guys.
I just learned C++, and to see if I have learned anything, I decided to code a calculator program all by myself. I am using xcode on Mac OS X 10.5, and I have coded this so far,
Code:
#include <iostream>
using namespace std;
int main() //Calculator program!!!!
{
int add, subtract, multiply, divide, add1, add2, addAnswer, subtract1, subtract2, subtractAnswer, multiply1, multiply2, multiplyAnswer, divide1, divide2, divideAnswer;
cout << "Please choose the operation!";
if (cin >> add)
{
cout << "Enter first addend!";
cin >> add1;
cout << "Enter second addend!";
cin >> add2;
addAnswer = (add1 + add2);
cout << "Answer is " << addAnswer << "!";
}
if (cin >> subtract)
{
cout << "Enter first minuend!";
cin >> subtract1;
cout << "Enter second subtrahend!";
cin >> subtract2;
subtractAnswer = (subtract1 - subtract2);
cout << "Answer is " << subtractAnswer << "!";
}
if (cin >> multiply)
{
cout << "Enter first multiple!";
cin >> multiply1;
cout << "Enter second multiple!";
cin >> multiply2;
multiplyAnswer = (multiply1 * multiply2);
cout << "Answer is " << multiplyAnswer << "!";
}
if (cin >> divide)
{
cout << "Enter first dividend!";
cin >> divide1;
cout << "Enter second divisor!";
cin >> divide2;
divideAnswer = (divide1 / divide2);
cout << "Answer is " << divideAnswer << "!";
}
return 0;
}
I did cmd apple r to get to the console menu, then built and go. It says
"Please choose the operation!"
then I say add or something, then it says
"The Debugger has exited with status 0."
Can you find a problem? I need to fix it so I can learn from my mistake. This is for my learning purposes! Thx