Hello everyone. I am new to c++ and I just wrote a program. I am on linux so just saying. This is the code. What keeps happening is all the commands just keep coming. here is an example.
Welcome to the Calculator. Please enter your operation.
addition
Please enter your first number.
Please enter your second number.
0Please enter your first number.
Please enter your second number.
0Please enter your first number.
Please enter your second number.
Floating point exception (core dumped)
Also need help on wait/sleep command if there is one. Thanks!
`/This is a basic calculator. V.01/
#include <iostream>
#include <unistd.h>
using namespace std;
int main()
{
int a, b, c, sum, pro, dif, div, end, addition, subtraction, division, multiplication, multiiplication, multiplucation, subtriction, diviision, diivision, adition, addishun, sutraction, subtrraction;
start:
cout << "Welcome to the Calculator. Please enter your operation. \n";
cin >> c;
if( c == addition)
goto add;
else if( c == subtraction)
goto sub;
else if( c == division)
goto divis;
else if( c == multiplication)
goto multi;
else if( c == multiiplication, multiplucation, subtriction, diviision, diivision, adition, addishun, sutraction, subtrraction)
goto spell;
/*Basic computations start here*/
add:
{ cout << "Please enter your first number. \n";
cin >> a;
cout << "Please enter your second number. \n";
cin >> b;
sum = a + b;
cout << sum;
}
sub:
{cout << "Please enter your first number. \n";
cin >> a;
cout << "Please enter your second number. \n";
cin >> b;
dif = a-b;
cout << dif;}
divis:
{cout << "Please enter your first number. \n";
cin >> a;
cout << "Please enter your second number. \n";
cin >> b;
dif = a / b;}
multi:
{cout << "Please enter your first number. \n";
cin >> a;
cout << "Please enter your second number. \n";
cin >> b;
end = a * b;
cout << end;}
spell:
{cout << "Spelling error. Restarting program";
sleep(4);
goto start;}
return 0;
}
`