8. A country has coins of denomination 3, 5 and 10 respectively. Write a recursive function canchange() which returns -1 if it is not possible to pay a value of k using these coins. Otherwise, it returns the minimum number of coins needed to make the payment. For example, canchange(7) will return -1. On the other hand, canchange(14) will return 4 because 14 can be paid as 3+3+3+5 and there is no other way to pay with fewer coins

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter15: Recursion
Section: Chapter Questions
Problem 6PE
icon
Related questions
Question
8. A country has coins of denomination 3, 5 and 10 respectively. Write a recursive function
canchange() which returns -1 if it is not possible to pay a value of k using these coins.
Otherwise, it returns the minimum number of coins needed to make the payment. For example,
canchange(7) will return -1. On the other hand, canchange(14) will return 4 because 14 can be
paid as 3+3+3+5 and there is no other way to pay with fewer coins
Transcribed Image Text:8. A country has coins of denomination 3, 5 and 10 respectively. Write a recursive function canchange() which returns -1 if it is not possible to pay a value of k using these coins. Otherwise, it returns the minimum number of coins needed to make the payment. For example, canchange(7) will return -1. On the other hand, canchange(14) will return 4 because 14 can be paid as 3+3+3+5 and there is no other way to pay with fewer coins
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Declaring and Defining the Function
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning