Answer to Question #172881 in C++ for Keega

Question #172881

Write an inline function sum() with four parameters that calculates the

arguments

provided and returns their sum.

Parameters: Four variables of type long.

Returns: The sum of type long.

Use the default argument 0 to declare the last two parameter.


1
Expert's answer
2021-03-18T08:01:00-0400
#include <iostream>

using namespace std;
inline long sum(long num1, long num2, long num3 = 0, long num4 = 0) 
{ 
    long sum = num1+num2+num3+num4;
    return sum;
} 


int main()
{
    cout<<sum(1,4,3,2);
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS