CJCoding With Joseph
15free / daySign inCreate account

Function Overloading: Add

Write two overloaded functions both named add: one taking two ints and returning their int sum, and one taking two doubles and returning their double sum. Call add(2, 3) and print the result, then call add(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 right add based on the argument types.

Expected Output:

5
4.00

= newline. The output ends with a newline — print one after the last line.

Hints3 available
Topics:
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.