I kept getting errors and warnings on this code, but before I post the errors, I am sure you can pick them out by yourselves with this being such a low level code.
Code:#include <iostream>
using namespace std;
int add()
{
unsigned long int a;
unsigned long int b;
cout << "\nFirst number: ";
cin.get >> a;
cout << "\nSecond number: ";
cin.get >> b;
cout << "\nAnswer: ";
cout << a + b;
cin.get;
menu();
return 0;
}
int subtract()
{
unsigned long int a;
unsigned long int b;
cout << "\nFirst number: ";
cin.get >> a;
cout << "\nSecond number: ";
cin.get >> b;
cout << "\nAnswer: ";
cout << a - b;
cin.get;
menu();
return 0;
}
int multiply()
{
unsigned long int a;
unsigned long int b;
cout << "\nFirst number: ";
cin.get >> a;
cout << "\nSecond number: ";
cin.get >> b;
cout << "\nAnswer: ";
cout << a * b;
cin.get;
menu();
return 0;
}
int devide()
{
unsigned long int a;
unsigned long int b;
cout << "\nFirst number: ";
cin.get >> a;
cout << "\nSecond number: ";
cin.get >> b;
cout << "\nAnswer: ";
cout << a / b;
cin.get;
menu();
return 0;
}
int menu()
{
int choice;
cout << "1. Add\n";
cout << "2. Subtract\n";
cout << "3. Multipply\n";
cout << "4. Devide\n";
cout << "\n";
cout << "Choice: ";
cin.get >> choice;
if (choice='1') {
add();
}
else if (choice='2') {
subtract();
}
else if (choice='3') {
multiply();
}
else if (choice='4') {
devide();
}
else {
cout << "Invalid option.";
menu();
}
return 0;
}
int main()
{
menu();
return 0;
}