Write a program with a function that takes two int parameters, adds them together, then
returns the sum. The program should ask the user for two numbers, then call the function
with the numbers as arguments, and tell the user the sum.
#include <iostream>
using namespace std;
int sum(int a, int b)
{
return a + b;
}
int main()
{
int a, b;
cout<<"Enter the first number...\n";
cin>>a;
cout<<"Enter the second number...\n";
cin>>b;
cout<<"The sum of "<<a<<" and "<<b<<" is "<<sum(a, b);
return 0;
}
Comments
Leave a comment