Question: Using either default parameters or overloading, write function ( s ) that return the proper results for the calls: getTotalChange ( 4 ) ; /

Using either default parametersor overloading, write function(s) that return the proper results for the calls:
getTotalChange(4);//4 pennies - returns 4
getTotalChange(2,3);//2 pennies, 3 nickels, returns 17
getTotalChange(1,2,3);//1 penny, 2 nickels, 3 dimes, returns 41
getTotalChange(4,2,1,3);//4 pennies, 2 nickels, 1 dime, 3 quarters, returns 99
Code:
1
#include
2
using namespace std;
3
// Do not modify anything on or above the line below this
4
// YOUR_CODE_BELOW
5
6
// YOUR_CODE
7
8
// YOUR_CODE_ABOVE
9
// Do not modify anything on or below the line above this
10
11
int main(){
12
int result = getTotalChange(4);
13
cout << result <<"";
14
result = getTotalChange(2,3);
15
cout << result <<"";
16
result = getTotalChange(1,2,3);
17
cout << result <<"";
18
result = getTotalChange(4,2,1,3);
19
cout << result <<"";
20
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!