Suppose that nickels and pennies disappear from the currency
Solution
In below program enter value of n and You can see for all value of n which is greater than 4 we can pay and we also got the value of x(number of dimes) and y(number of quarter) .
#include <iostream>
 using namespace std;
int main()
 {
 int n,i;
 int amt;
 cout << \"Enter value of n \" << endl;
 cin >> n;
 for(i=4;i<n;i++)
 {
 amt=5*i;
 int x=0,y=0;
 if(amt %10 == 0 || amt %25 ==0)
 {
 if(amt % 10 ==0)
 {
 while(10*x != amt)
 x++;
 }
 else if(amt%25 == 0)
 {
 while(25*y != amt)
 y++;
 }
 cout << \"Pay for n= \" << i <<\" and the amount is \" << 5*i << \" x = \" << x << \" y = \" << y << endl;
 }
 else
 {
 while(amt > 5)
 {
 if(amt >= 25)
 {
 amt-=25;
 y++;
 if(amt %10 == 0)
 {
 while(10*x != amt)
 x++;
 amt=0;
 }
 }
 else if(amt >=10)
 {
 amt-=10;
 x++;
 }
 }
 if(amt == 0)
 cout << \"Pay for n= \" << i <<\" and the amount is \" << 5*i << \" x = \" << x << \" y = \" << y << endl;
 else
 cout << \"can not pay n= \" << i << \" and the amount is \" << 5*i << endl;
 }
 
 }
 return 0;
 }


