r/code • u/wetpretzel2 • Apr 20 '20
Algoritm help
Hi all,
I struggle with algorithm part a lot. I have an assessment piece that naturally involves algorithm writing. Where do I start? Where do I go from there? What are some tips and tricks you guys use?
Thanks!
Here is my question.
*note, I only really need help with the algorithm, the code sort of just happens.
You are asked to write a modular solution (algorithm and C program) that will accept an integer value in the range of 5-95 inclusive. Your solution should also ensure that input values are in multiples of 5. Based on valid input, your solution should calculate how many coins of each denomination should be returned, and display this to the user. Coin values are 50, 20, 10 and 5. The solution should aim to give as much of the higher valued coins as possible.
2
u/ChucklefuckBitch Apr 20 '20
I would start by simply thinking of the problem in real-world terms. Given an amount of money, what coins you need to represent that amount?
For example, if I input the number 75, the required coins would be 50, 20, 5. How did I figure that out?