Saturday, 23 March 2013

Using Functions make Calculator by return their results C++


#include<iostream.h>
int add(int x,int y){return x+y;}
int sub(int x,int y){return x-y;}
int mult(int x,int y){return x*y;}
 int div(int x,int y){return x/y;}
int main()
{
int a,b;
cout<<"enter any two numbers:";
cin>>a>>b;
cout<<"sum = "<<add(a,b);
 cout<<"\nsub = "<<sub(a,b);
 cout<<"\nmultiply = "<<mult(a,b);
  cout<<"\ndivide = "<<div(a,b);
  }