Friday 24 January 2020

Substraction of two numbers in CPP (Using Function)

Source Code -
#include<iostream>
using namespace std;
void subtract(int a,int b)
{
int c;
c=a-b;
cout<<"The subtraction of the two numbers are: ";
cout<<c;
}

int main()
{
int x,y;
cout<<"Enter two numbers: ";
cin>>x>>y;
subtract(x,y);
return 0;

}

Program Output -
Enter two numbers: 9
5
The subtraction of the two numbers are: 4

No comments:

Post a Comment