Thursday 23 January 2020

Sum of two numbers in CPP (Using Function)

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

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

Program Output :
Enter two numbers: 5
6

The sum of the numbers are: 11

No comments:

Post a Comment