← Back to Functions
Question 409
Function Overloading: Add
Function Overloading: Add
Write two overloaded functions both namedadd: one taking twoints and returning theirintsum, and one taking twodoubles and returning theirdoublesum. Calladd(2, 3)and print the result, then calladd(2.5, 1.5)and print that result with exactly 2 decimal places. The output must be exactly what is shown in Expected Output. The compiler picks the rightaddbased on the argument types.
Expected Output:
5 4.00
= newline. The output ends with a newline — print one after the last line.
Hints3 available
Sign in to use hintsTopics:
Functions
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (cout, fori)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.