11-10-2009, 11:16 PM
Code:
#include <iostream>
using namespace std;
int addition (int a,int b)
{
int r;
r=a+b;
return(r);
}
int subtraction (int a,int b)
{
int r;
r=a-b;
return(r);
}
int multiplication (int a,int b)
{
int r;
r=a*b;
return(r);
}
int division (int a,int b)
{
int r;
r=a/b;
return(r);
}
int main ()
{
int z;
int a1;
int a2;
int o;
cout << "First number" << endl;
cin >> a1;
cout << "Second number" << endl;
cin >> a2;
cout << "1) Addition" << endl;
cout << "2) Subtraction" << endl;
cout << "3) Multiplication" << endl;
cout << "4) Division" << endl;
cout << "What operation?: ";
cin >> o;
if (o == 1) {
z = addition (a1,a2);
}
else {
if (o == 2) {
z = subtraction(a1,a2);
}
else {
if (o == 3){
z = multiplication (a1,a2);
}
else {
if (o ==4){
z = division (a1,a2);
}
}
}
}
cout << "The result is " << z << endl;
return 0;
}