In this program, you'll learn to add two numbers using function.
A function is a block of statements that performs a specific task. Let's say you are writing a C program and you need to perform a same task in that program more than once. In such case you have two options:
a) Use the same set of statements every time you want to perform the task.
b) Create a function to perform that task, and just call it every time you need to perform that task.
#include<iostream>
using namespace std;
void add(int, int);
int main()
{
int a, b;
cout<<"Enter two number: ";
cin>>a>>b;
add(a,b);
return 0;
}
void add(int a, int b)
{
cout<<"Addition of "<<a<<" and "<<b<<" is"<<a+b;
}
Enter two number: 12 68
Addition of 12 and 68 is 80