calculator c++ solution code example
Example: calculator with c++
#include <iostream>
using namespace std;
int main()
{
int choice;
cout << 1 << endl;
cout << 2 << endl;
cout << 3 << endl;
cout << 4 << endl;
cout << "Choice A Number: ";
cin >> choice;
if (choice >= 1 && choice <= 4)
{
int a, b;
cout << "Enter Num One: ";
cin >> a;
cout << "Enter Num Two: ";
cin >> b;
if (choice == 1)
cout << a << "+" << b << "=" << a + b << endl;
if (choice == 2)
cout << a << "-" << b << "=" << a - b << endl;
if (choice == 3)
cout << a << "*" << b << "=" << a * b << endl;
}
else
{
cout << "Wrong Choice" << endl;
}
}