C++ Program to do Addition,subtraction and multiplication of two numbers using function

C++ Program to do Addition,subtraction and multiplication of two numbers using function

#include<iostream.h>
#include<conio.h>

int res;
void main()
{
clrscr();
int sum(int,int);
int sub(int,int);
int mul(int,int);
int a,b,m,su,s;
cout<<“Enter two numbers:”;
cin>>a>>b;

s=sum(a,b);
su=sub(a,b);
m=mul(a,b);
cout<<“Sum:”<<s<<“nSubtraction:”<<su<<“nMultiplication:”<<m;
getch();
}

sum(int a,int b)
{
res=a+b;
return(res);
}

sub(int a,int b)
{
res=a-b;
return(res);
}

mul(int a,int b)
{
res=a*b;
return(res);
}

4 thoughts on “C++ Program to do Addition,subtraction and multiplication of two numbers using function”

  1. is it okay ?
    #include
    using namespace std;
    void add();
    void sub();
    int main(){
    add();
    sub();

    }
    void add()
    {
    int a,b;
    cout<>a>>b;
    cout<<a+b;

    }
    void sub()
    {
    int a,b;
    cout<>a>>b;
    cout<<a-b;
    }

  2. Write a C++ program to perform following arithmetic operations using functions(pass
    by reference):
    1. Twice() // multiplying by two
    2. Divide() //divide the argument value by 3
    3. Calculate() // perform following calculations
    x= 5x + 7
    y= 2x – 3
    z= 5x + 2x
    Plz help me with this program

Leave a Comment

Your email address will not be published. Required fields are marked *