You are using a version without Ads of this website. Please, consider donating:

### Help with function programs

I have the following program that works great, but I don't know how to set it up using a "main" and "function" program using the following specifications:

- Change has one input – an amount of change to be returned between 0 and 99 cents
- Change has four outputs – the number of quarters, dimes, nickels, and cents to be returned.
- Prompt the user in the main function to enter an integer from 0 to 99 corresponding to an amount of change to be returned.
- Call the function in the main program.

-The main program should display the number of quarters, dimes, nickels, and cents to be returned (with descriptive names, such as:
Number of quarters = 2)

 ``12345678910111213141516171819202122232425262728293031`` ``````#include using namespace std; int main() { int quarters, dimes, nickles, pennies; cout << "Enter the number of quarters: "; cin >> quarters; cout << "Enter the number of dimes: "; cin >> dimes ; cout << "Enter the number of nickles: "; cin >> nickles ; cout << "Enter the number of pennies: "; cin >> pennies ; cout << "\n"; cout << "Quarters: " << quarters << endl; cout << "Dimes: " << dimes << endl; cout << "Nickels: " << nickles << endl; cout << "Pennies: " << pennies << endl; cout << "\n"; float money; // amount of money i have money = (quarters * 0.25) + (dimes * 0.10) + (nickles * 0.05) + (pennies * 0.01); cout << "Your total is: \$"<< money << endl; return 0; }``````
Last edited on
What do you want your function to do?
Topic archived. No new replies allowed.