# Help with small simple program

• 04-02-2005
Sonor
Help with small simple program
*This is not a graded project*

Hey guys,

I'm doing a small project for my college homework and it requires me to write a simple program for the following question except I"m late in the course with only small knowledge in C.

If someone would give us a hand it be great (i dont want the whole thing to be written out for me I'd like to learn as much as I can)

The question is as follows: "You are asked to write a simple program that will accept an integer value in the range of 5-95 and in increments of 5 at a time, representing the number of cents to give to a customer in their change. The program should calculate how many coins of each denomination and display this to the user. Valid coin values are 50, 20, 10 and 5. Your solution (program and algorithm) should be modular in nature. This requires the submission of a high-level algorithm and suitable decompositions of each step."

All this requires is a simple notepad code i think using #include <stdio.h> etc. I am able to compile this myself.

I thought I'd be able to do this but I cant get it started lol. *This is not a graded project*
• 04-02-2005
0rion
Think of the steps on how you want to calculate (i.e. the algorithm) before you jump into the code.

So let's say I input 70 cents. What can I do to divide them into 50/20/10 and 5 cent coins?

By integer division.
70/50 = 1
The remainder after this is 70%50 = 20
20/20 = 1
The remainder after this is 20%20 = 0
Terminate once you reach 0.

Likewise, if I input 95 cents:

95/50 = 1
95%50 = 45
45/20 = 2
45%20 = 5
5 / 10 = 0
5 % 10 = 5
5 / 5 = 1
5 % 5 = 0

See the pattern? Hope it gets you started :)
• 04-02-2005
Salem
Well step 1 is write the "hello world" program to make sure you can edit code, compile it and run it.

Then move on to actually solving the problem. My first suggestion is read in a number, then print it out again unchanged.
• 04-02-2005
Salem
Or until someone just hands out the answer without any further effort required :(
• 04-02-2005
0rion
Ek, I didn't type out any code only gave some pretty good hints on how to solve the problem :)
*Assuming you are referring to me*
• 04-02-2005
Sonor
haha ive done all those hello world programs n stuff i just need help how to get started on solving for what the question asks, and orion did that so appreciate that thankyou!

now i must turn this into a algorithm then code. thanks for your help guys.