# Greedy; Pset 1 - Trouble creating modulo algorithm

``````int q=coins/25; //gives number of quarters

int mq=coins%25; gives modulo quarters
int md=mq/10;
int mn=md/5;
int mp=mn/1;

printf("%d, %d, %d, %d,", q+md+mn+mp);
``````

So I've been able to prompt the user for a float and convert that float to an int*100. The trouble is with my algorithm - I'm not sure where to go from here.

This code currently prints the number of quarters, plus the modulo's for dimes, nickels, and pennies. My above code allows me to pass all of the check50 inputs above \$1 - nothing below, so I imagine I've made all of my variables dependent on the quarter. I was trying to figure out an efficient way to do the same thing with the other coins, but it just seems like too many variables.

I feel like I'm on the right track but another set of eyes would be a big help right now. Any advice is welcome. Thanks so much.

`int mq=coins%25;` actually gives you the change left after removing all the quarters. int md=mq/10; This is that change divided by 10, but it's an integer divide, so there's no remainder. It will give the number of dimes in the change, but the remainder is abandoned. int mn=md/5; Now it gets bizarre. This is the number of dimes that were counted divided by 5. The logic has gone totally off the rails. int mp=mn/1; Same kind of result as for nickels.