Tuesday, 16 December 2014

C++ ADD TWO NUMBERS USING FUNCTION

Write a program using function to add two numbers.

#include<iostream.h>
#include<conio.h>
int add(int,int);
void main()
{
int a,b,c;
cout<<"Enter two numbers:"<<endl;
cin>>b;
cin>>c;
a=add(b,c);
cout<<"The sum of the two numbers is :" <<a<<endl;
getch();
}
int add(int x, int y)
{
return x+y;
}

OUTPUT:
Enter two numbers:
4 4
The sum of the two numbers is: 8

No comments:

Post a Comment