Description:
This program perform different operation of calculator.
Code:
This program perform different operation of calculator.
Code:
#include<iostream>
#include<conio.h>
using namespace std;
int sum(int,int);
int difference(int,int);
int multiplication(int,int);
float division(int,int);
int average(int,int);
int s=0,d=0,m=0,g=0;float v=0;
int main()
{
int a,b;
cout<<"enter first number"<<endl;
cin>>a
cout<<"enter second number"<<endl;
cin>>b;
s= sum (a,b);
cout<<s<<endl;
d= difference (a,b);
cout<<d<<endl;
m= multiplication (a,b);
cout<<m<<endl;
v= division (a,b);
cout<<v<<endl;
g= average (a,b);
cout<<g<<endl;
cout<<"ok";
getche();
return 0;
}
int sum (int x,int y)
{
s=x+y;
cout<<"sum="<<endl;
return s;
}
int difference (int x,int y)
{
d=x-y;
cout<<"difference="<<endl;
return d;
}
int multiplication (int x,int y)
{
m=x*y;
cout<<"multiplication="<<endl;
return m;
}
float division (int x,int y)
{
v=x/y;
cout<<"division="<<endl;
return v;
}
int average (int x,int y)
{
g=(x+y)/2;
cout<<"average="<<endl;
return g;
}
No comments:
Post a Comment