Skip to content

Instantly share code, notes, and snippets.

@rizwansoaib
Created January 7, 2018 04:39
Show Gist options
  • Select an option

  • Save rizwansoaib/8b937f8bd162bc58663ca4e1bd13a4ce to your computer and use it in GitHub Desktop.

Select an option

Save rizwansoaib/8b937f8bd162bc58663ca4e1bd13a4ce to your computer and use it in GitHub Desktop.
Find minimum currency required
#include <stdio.h>
void main()
{
int a,x,i=0;
printf("Here are 1,2,5,10,20,50,100 currency you will enter amount and program tell minimum currency required\n");
printf("Please Enter Amount\n");
scanf("%d",&x);
int b=x;
if(x/100!=0)
{
a=x/100;
x=x%100;
i=i+a;
printf("%d is 100rs Note\n",a);
}
if(x/50!=0)
{
a=x/50;
x=x%50;
i=i+a;
printf("%d is 50rs Note\n",a);
}
if(x/20!=0)
{
a=x/20;
x=x%20;
i=i+a;
printf("%d is 20rs Note\n",a);
}
if(x/10!=0)
{
a=x/10;
x=x%10;
i=i+a;
printf("%d is 10rs Note\n ",a);
}
if(x/5!=0)
{
a=x/5;
x=x%5;
i=i+a;
printf("%d is 5rs Note\n",a);
}
if(x/2!=0)
{
a=x/2;
x=x%2;
i=i+a;
printf("%d is 2rs Note\n",a);
}
if(x==1)
{
i++;
printf("1 is 1rs note\n");
}
printf("%d is minimum Note is required for %d",i,b);
}
@rizwansoaib
Copy link
Copy Markdown
Author

To find minimum currency required for given amount

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment