Code:
#include <stdio.h>
void insert_money(int p, int n, int d, int q, int total)
{
printf("How much of each coin do you want to insert: \n");
printf("Quarters: ");
scanf("%d", &q);
printf("Dimes: ");
scanf("%d", &d);
printf("Nickels: ");
scanf("%d", &n);
printf("Pennies: ");
scanf("%d", &p);
}
void return_dollars(int p, int n, int d, int q, int dollars, int total)
{
total = 25*q + 10*d + 5*n + p;
dollars = total/100;
total = p % 100;
printf("\nYou have this many Dollars: %d\n", dollars);
}
void remove_money(int p, int n, int d, int q, int total)
{
q = total/25;
total = p % 25;
d = total/10;
total = p % 10;
n = total/5;
total = n % 5;
}
void display(int p, int n, int d, int q)
{
printf("You have this many Quarters: %d\n", q);
printf("You have this many Dimes: %d\n", d);
printf("You have this many Nickels: %d\n", n);
printf("You have this many Pennies: %d\n", p);
}
void main()
{
int p, n, d, q, dollars, total;
insert_money(p, n, d, q, total);
return_dollars(p, n, d, q, dollars, total);
remove_money(p, n, d, q, total);
display(p, n, d, q);
}