C++ program using function which accept two integers as an argument and return its sum.
Source Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
| #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;
}
|
Enter first number : 45
Enter second number : 56
The sum is : 101
Post a Comment
Click to see the code!
To insert emoticon you must added at least one space before the code.