#include <iostream>
using namespace std;
int add ()
{
float a, b;
cout <<"Input the two numbers: \n";
cin >> a >> b;
float c = a+b;
cout<< "The sum is: " << c<< endl;
return 0;
}
int sub ()
{
float d,e;
cout << "input the first and second number: \n";
cin >> d >> e;
float f = d-e ;
cout << "The difference is: "<< f<< endl;
return 0;
}
int product ()
{
float g,h;
cout<< "Input the two numbers: \n";
cin>> g >> h;
float i = g*h;
cout<<"The product is : " << i<< endl;
return 0;
}
int division ()
{
float j,k;
cout<< "Input the first and second number: \n";
cin>>j >>k;
float l = j/k ;
cout<<"The division is : " <<l << endl;
return 0;
}
int mod()
{
int m, n;
cout <<"Input the first and second number: \n";
cin >> m >> n;
int o = (m % n );
cout << "The modulus is : " << o<< endl ;
return 0;
}
int factorial()
{
int p,q,r;
r = 1;
cout<<"Enter the number : ";
cin >> p;
{
if( p != 0)
{
for (q= p; q>0 ; q--)
{
r *= q;
}
cout<< "The factorial is : "<< r<< endl;
}
else
{
cout<<"Math error! \n";
}
}
return 0;
}
int main()
{
int option;
cout<<"\nThanks for using our calculator\n" <<"What would you like to do? \n"
<< 1 <<"> Addition \n" << 2<< "> Subtraction \n" << 3 << "> Multiplication \n"
<< 4<< "> Division \n" << 5 << "> Modulus\n"
<< 6 << "> Factorial \n" << 7 << "> Nothing\n" <<"Enter your option: ";
cin >> option;
switch (option)
{
case 1 :
add();
break;
case 2 :
sub ();
break;
case 3 :
product ();
break;
case 4 :
division ();
break;
case 5 :
mod();
break;
case 6:
factorial();
break;
case 7:
cout<<"Okay byeee.\n";
break;
default:
cout<<"You have entered the wrong option! \n" <<"Goodbye.\n";
return 0;
}