Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

PLease briefly explain what/how you\'re doing it too. Write a program to perform

ID: 639617 • Letter: P

Question

PLease briefly explain what/how you're doing it too.

Write a program to perform addition, subtraction, division, and multiplication on two floating point numbers. The program receives numeric input from the standard input stream. Display the results of each math operation. Answer the following question in the comments section of your program: What happens when your program divides by zero?

2) Write a program that asks the user to enter a U.S. dollar amount and then show how to pay that amount using the smallest number of $20, $10, $5, and $1 bills. (15 points) Enter a dollar amount: 93 $20 bills: 4 $10 bills: 1 $ 5 bills: 0 $ 1 bills: 3 Hint: Divide the amount by 20 to determine the number of $20 bills needed and then reduce the amount by the total value of the $20 bills. Repeat for other bill sizes. Be sure to use integer values throughout, not floating-point numbers. You may want to use the modulus operator %.

Explanation / Answer

#include <stdio.h>

int main(void)
{
int amount, bills;

printf(" Enter a dollar amount: ");
scanf("%d", &amount);

bills = amount / 20; /* Number of $20 bills needed */
printf(" $20 bills: %d ", bills);

amount = amount - (bills * 20);

bills = amount / 10; /* Number of $10 bills needed */
printf("$10 bills: %d ", bills);

amount = amount - (bills * 10);

bills = amount / 5; /* Number of $5 bills needed */
printf(" $5 bills: %d ", bills);

amount = amount - (bills * 5);

bills = amount / 1; /* Number of $1 bills needed */
printf(" $1 bills: %d ", bills);   

return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote