Okay, I am going to put a lot of time and effort into this post, so I hope you read it carefully and try to follow the process.
You started to break the problem down, but you should break it down further. Remember, computers need explicit instructions. Therefore, you should try to describe each and every little step separately. This makes converting the steps into code much easier.
Step 1: Break the problem down into a discrete list of steps.
Let's assume we start with an amount of $2.83
First, we convert this amount to cents: 283
Does this amount contain dollars?
If the amount is greater than or equal to a dollar, then yes.
To get the dollars, divide the amount by 100 (dollars = 283 / 100 = 2)
Now reduce the amount by the number of dollars we took out
amount = amount - 100 * dollars
That is the basic logic we need to follow, with each little step described. As you can see, even broken down this way, there is not a whole lot to it.
Fortunately, the rest of the code follows the same pattern. Let's continue the process.
Does this amount contain quarters?
If the amount is greater than or equal to a quarter, then yes.
To get the quarters, divide the amount by 25 (quarters = 83 / 25 = 3)
Now reduce the amount by the number of quarters we took out
amount = amount - 25 * quarters
Does this amount contain dimes?
If the amount is greater than or equal to a dime, then yes.
8 is not >= 10, so the number of dimes = 0.
Does this amount contain nickels?
If the amount is greater than or equal to a nickel, then yes.
To get the nickels, divide the amount by 5 (nickels = 8 / 5 = 1)
Now reduce the amount by the number of nickels we took out
amount = amount - 5 * nickels
Whatever is left over must be the pennies.
So we know that $2.83 contains: (2) dollars, (3) quarters, (0) dimes, (1) nickel, and (3) pennies.
Step 2: Convert these steps into code.
Now that we have the entire problem broken down in words, converting it to code is pretty straight-forward.
Let's start with the "dollars" section.
Does this amount contain dollars?
If the amount is greater than or equal to a dollar, then yes.
To get the dollars, divide the amount by 100 (dollars = 283 / 100 = 2)
Code:
dollars = amount / 100;
Now reduce the amount by the number of dollars we took out
amount = amount - 100 * dollars
amount = 283 - (100 * 2)
amount = 283 - 200
amount = 83
Code:
amount = amount - (100 * dollars);
Do you see how breaking the problem down into each little step helps us easily convert the algorithm into code?
I will stop at dollars, since the rest is the same idea.
Notice how I opted for subtraction and multiplication when re-adjusting the value of "amount", instead of using the modulus (%) as in the original example you posted. I did it this way because, as a beginner, it might be easier for you to see the logic expressed that way. It solves the problem clearly, so it is sufficient. When you get more experience, you will be able to find easier ways to do things - but for now, it would help to see things spelled out like that.
Anyway, I hope this was helpful for you. Let me know if you have any questions on any of this.