Simple Calculator inC++
#include <iostream>
using namespace std;
int main()
{
while (true)
{
cout << "Choose what u wan to do:";
cout << "1. Addition\n 2.Substraction\n 3.Division\n 4.Multiplication\n";
int i, j, k;
cin >> i;
cout << "Enter the two numbers : ";
cin >> j >> k;
switch (i)
{
case 1:
/* code */
cout << "The sum is " << j + k << endl
<< endl;
break;
case 2:
/* code */
cout << "The difference is " << j - k << endl
<< endl;
break;
case 3:
/* code */
cout << "After dividing we got " << j / k << endl
<< endl;
break;
case 4:
/* code */
cout << "The product is " << j * k << endl
<< endl;
break;
default:
break;
}
}
return 0;
}
Comments
Post a Comment