Knowing that ATMs should withdraw the minimum number of notes for each withdrawal, write a program that reads an amount of money in LL on the keyboard without telling the user to enter the value and then displays on the screen the minumum numbers of each currency notes 100000 LL, 50000 LL , 20000 LL, 10000 LL, 5000 LL and 1000 LL that this amount could be decomposed of and then go to a new line.

The amount of money is a positive integer number.

Example: Suppose the amount to be withdrawn is 212000 LL, so the minimum number of notes would be composed of 2 one hundred thousand notes + 0 fifthy thousand notes + 0 twenty thousand notes + 1 ten thousand notes + 0 five thousand notes + 2 one thousand notes.


Difficulty level
This exercise is mostly suitable for students
#include <stdio.h>
#include <math.h>
int main()
{
    int money;
    int c100, c50, c20, c10, c5, c1;
    
    scanf("%d",&money);
    c100 = money/100000;
    c50 = (money - c100*100000)/50000;
    c20= (money - c100*100000 - c50*50000)/20000;
    c10= (money - c100*100000 - c50*50000 - c20*20000)/10000;
    c5= (money - c100*100000 - c50*50000 - c20*20000 - c10*10000)/5000;
    c1= (money - c100*100000 - c50*50000 - c20*20000 - c10*10000 - c5*5000)/1000;
    
    printf("%d %d %d %d %d %d\n",c100,c50,c20,c10,c5,c1);
    

    return 0;
}

Back to the list of exercises
Looking for a more challenging exercise, try this one !!
Binary trees insertion