-
Quote:
Code:
#include <iostream.h>
#include <windows.h>
int main()
{
cout << "Stephen's C++ Calculator" << endl;
cout << "Enter a number" << endl;
int a;
cin << a;
cout << a << endl;
cout << "Now push a math sign" << endl;
int sign;
cin << sign;
cout << a <<""<< sign << endl;
cout << "Now push a second number" << endl;
int b;
cin << b;
if (sign == " + ");
{
int resultplus;
a + b = resultplus;
cout << resultplus << " is your answer!" << endl;
}
if(sign == " - ");
{
int resultminus;
a - b = resultminus;
cout << resultminus << " is your answer!" << endl;
}
if(sign == "/");
{
int resultdivide;
a / b = resultdivide;
cout << resultdivide << " is your answer!" << endl;
}
if(sign == "*");
{
int resultmultiply;
a * b = resultmultiply;
cout << resultmultiply << " is your answer!" << endl;
}
return 0;
}
It hurts me to admit that I actually posted this...
Edit: At least I can say my stupidity wasn't all my fault. I learned to declare variables from the RPGToolkit, so that's why I didn't declare them at the beginning of the main function. The RPGToolkit also didn't require variable initialization.
The reason I didn't use the standard headers is because I was using an outdated C++ book which, frankly, sucked.
-