CJCoding With Joseph

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:

5
4.00

The compiler picks the right add based on the argument types.

Expected Output:

5
4.00
Topics:
Functions
Code Editor
1
Tab to indent ยท Ctrl+Enter to run ยท 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.