#include<iostream>
#include<string>using namespace std;
double sum(double a, double b);
double sub(double a, double b);
double mul(double a, double b);
double div(double a, double b);
int main()
{
double first;
double second;
char choice;
cout << "Enter the first number : " << endl;
cin >> first;
cout << "Enter the operation do you want to perform : " << endl;
cin >> choice;
cout << "Enter the second number : " << endl;
cin >> second;
cout << "The result is : ";
switch (choice)
{
case '+':
cout << sum(first,second) << endl;
break;
case '-':
cout << sub(first, second) << endl;
break;
case '*':
cout << mul(first, second) << endl;
break;
case '/':
cout << div(first, second) << endl;
break;
}
cout << endl;
system("pause");
return 0;
}
double sum(double a, double b) {
return a + b;
}
double sub(double a, double b) {
return a - b;
}
double mul(double a, double b) {
return a*b;
}
double div(double a, double b) {
return a / b;
}
No comments:
Post a Comment