Write a program using function which accept two integers as an argument and return its sum. Call this function from main( ) and print the results in main( ).

Source Code

#include<iostream>
using namespace std;

int sum(int, int);

int main()
{
	int x,y,s;
	cout<<"Enter first number : ";
	cin>>x;
	cout<<"Enter second number : ";
	cin>>y;
	s=sum(x,y);
	cout<<"The sum is : "<<s;

	
	return 0;
}

int sum(int a, int b)
{

	int total;
	total=a+b;
	return total;
}


Output

Enter first number : 45
Enter second number : 56
The sum is : 101