Question: Write a program that accepts an integer input from the user and display the least number of combinations of 200s, 100s, 50s, 20s, 10s, 5s,

Write a program that accepts an integer input from the user and display the least number of combinations of 200s, 100s, 50s, 20s, 10s, 5s, and 1s.

[Test your solution using this samples]

a. Input: 250

Output: 1x200s, 1x50s

b. Input: 1127

Output: 5x200s, 1x100s, 1x20s, 1x5s, 2x1s

c. Input: 1127

Output: 5x200s, 1x100s, 1x20s, 1x5s, 2x1s

d. Input: 19

Output: 1x10s, 1x5s, 4x1s

  • Use division to determine the number of occurrence of each element (i.e. 200, 100) in the input (e.g. Given 500 if we divide it by the largest number possible; which is 200; we will get 2. Therefore, there are 2x200s.)
  • Use subtraction to determine the remaining value of the input. (e.g. In the 500 example, since there are 2x200s, we still have 100 to process. The 100 came from 500 – (2*200) = 100.)
  • Use the next largest number possible (i.e. 100) to check the number of occurrence. Continue until the remaining value of the input is zero.

Step by Step Solution

3.51 Rating (154 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

include int main intabcdefgn printfEnter the number scanfdn an200 ifa1 nn200a printfdx200... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!

Related Book