Thursday 23 January 2020

Simple method to subtract of two numbers in CPP

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
2

The subtraction of the two numbers are: 7

No comments:

Post a Comment