Combination of Money for desired money

Problem Statement
write a c program to first take input from user,then print all the combination of money that can lead to the same sum given by user
#include<stdio.h>
int main()
{
  int total,rs_5,rs_10,rs_20,rs_50,rs_100;
  printf("enter totaL AMOUNT OF MONEY \n");
  scanf("%d",&total);
  for(rs_5=0;rs_5<=total;rs_5=rs_5+5)
    {
      for(rs_10=0;rs_10<=total;rs_10=rs_10+10)
{
 for(rs_20=0;rs_20<=total;rs_20=rs_20+20)
   {
     for(rs_50=0;rs_50<=total;rs_50=rs_50+50)
{
 for(rs_100=0;rs_100<=total;rs_100=rs_100+100)
   {
     if(rs_100+rs_50+rs_20+rs_10+rs_5==total)
{
 printf("amount of 5=%d,amount of 10=%d,amount of 20=%d, amount of 50=%d,amount of 100=%d \n",rs_5,rs_10,rs_20,rs_50,rs_100);
}
   }
}
   }
}
    }
  return 0;
}



No comments:

Post a Comment