Ask Question

Write a C program that asks the user to enter a US dollar amount and then shows how to pay that amount using the smallest number of $20,$10,$5 and $1 bills. Enter a dollar amount: 93

$20 bills: 4

$10 bills: 1

$5 bills: 0

$1 bills: 3

+1
Answers (1)
  1. 5 November, 18:26
    0
    Here is code in C.

    #include

    //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
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Write a C program that asks the user to enter a US dollar amount and then shows how to pay that amount using the smallest number of ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers