Here is code in C.
#include <stdio.h>
//main function
int main(void)
{ //variable to store input amount
int amount;
printf("Enter a dollar amount:");
//reading the input amount
scanf("%d",&amount);
//calcutating and printing the $20 bills
printf("\n$20 bills:%d",amount/20);
//update the amount After reducing the $20 bills
amount=amount%20;
//calcutating and printing the $10 bills
printf("\n$10 bills:%d",amount/10);
//update the amount After reducing the $10 bills
amount=amount%10;
//calcutating and printing the $5 bills
printf("\n$5 bills:%d",amount/5);
//update the amount After reducing the $5 bills
amount=amount%5;
//calcutating and printing the $1 bills
printf("\n$1 bills:%d",amount/1);
return 0;
}
Explanation:
According to the code, first it will ask user to give input amount.Then it will find the total bills for $20 and print that number, then it update the amount value after reducing them from the amount.Then it will calculate total bills for $10 and print that number then it updates the amount after reducing them from amount.Similarly it will calculate for $5 bills and $1 bills and print their values.
Output:
Enter a dollar amount:93
bills of $20 :4
bills of $10 :1
bills of $5 :0
bills of $1 :3