Hi!
I'm just started learning C++ and i tried to do a calculator for fun.
I did not succeed :$
There is an error here that i cannot find... Please, if you find it let me know :icon_smile:
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
double num1;
double num2;
char sign;
cout << "Once you enter a number press \"ENTER\"" << endl;
cin >> num1;
cin >> sign;
cin >> num2;
cout << "The result is ";
if (sign == '+'){
cout << num1+num2;
}
else if(sign == '-'){
cout << num1-num2;
}
else if(sign == '*'){
cout << num1*num2;
}
else if(sign == '/'){
cout << num1/num2;
}
else{
cout <<"Please enter +,-,* or /";
}
return 0;
}
Every time I run the program I type (example):
5
+
5
Then i press RETURN and the program collapses.