#include<iostream.h>
void add(float* , float*); // function declaration
void sub(float* , float*); // function declaration
void mul(float* , float*); // function declaration
void div(float* , float*); // function declaration
int main(){
char option;
float a;
float b;
cout << "Choose from the following options: " << endl;
cout << "+ : Plus" << endl;
cout << "- : Minus" << endl;
cout << "* : Multiply" << endl;
cout << "/ : Divide" << endl;
cin >> option;
cout << "Enter first number: "; cin >> a;
cout << "Enter second number: "; cin >> b;
switch (option){
case '+':
add(&a, &b);
break;
case '-':
sub(&a, &b);
break;
case '*':
mul(&a, &b);
break;
case '/':
div(&a, &b);
break;
default:
cout << "Wrong option. Run again.";
} // end switch
return 0;
} // end main()
// ========= () ================
void add(float* x, float* y){
cout << *x << " + " << *y << " = " << ((*x) + (*y));
return;
}
// ========= () ================
void sub(float* x , float* y) {
cout << *x << " - " << *y << " = " << ((*x) - (*y));
return;
}
// ========= () ================
void mul(float* x, float* y){
cout << *x << " * " << *y << " = " << ((*x) * (*y));
return;
}
// ========= () ================
void div(float* x, float* y){
cout << *x << " / " << *y << " = " << ((*x) / (*y));
return;
}
void add(float* , float*); // function declaration
void sub(float* , float*); // function declaration
void mul(float* , float*); // function declaration
void div(float* , float*); // function declaration
int main(){
char option;
float a;
float b;
cout << "Choose from the following options: " << endl;
cout << "+ : Plus" << endl;
cout << "- : Minus" << endl;
cout << "* : Multiply" << endl;
cout << "/ : Divide" << endl;
cin >> option;
cout << "Enter first number: "; cin >> a;
cout << "Enter second number: "; cin >> b;
switch (option){
case '+':
add(&a, &b);
break;
case '-':
sub(&a, &b);
break;
case '*':
mul(&a, &b);
break;
case '/':
div(&a, &b);
break;
default:
cout << "Wrong option. Run again.";
} // end switch
return 0;
} // end main()
// ========= () ================
void add(float* x, float* y){
cout << *x << " + " << *y << " = " << ((*x) + (*y));
return;
}
// ========= () ================
void sub(float* x , float* y) {
cout << *x << " - " << *y << " = " << ((*x) - (*y));
return;
}
// ========= () ================
void mul(float* x, float* y){
cout << *x << " * " << *y << " = " << ((*x) * (*y));
return;
}
// ========= () ================
void div(float* x, float* y){
cout << *x << " / " << *y << " = " << ((*x) / (*y));
return;
}