Modify the program below with the following function : void pay_amount(int dolla
ID: 3641645 • Letter: M
Question
Modify the program below with the following function :
void pay_amount(int dollars, int*twenties, int*tens, int*fives, int*ones)
program:
#include <stdio.h>
int main(void)
{
int dllramt; int ten; int five; int twenty; int ones; //Initializes the variables
printf("Enter Dollar Amount:"); //ask user for dallar amount
scanf_s("%d",&dllramt); //user inputs dollar amount
twenty = dllramt / 20; //Divides dollar amount by 20
dllramt = dllramt % 20; //remainder after deviding by 20
ten = dllramt / 10; //Divides dollar amount by 10
dllramt = dllramt % 10; //remainder after deviding by 10
five = dllramt / 5; //Divides dollar amount by 5
% 5; //remainder after deviding by 5
printf("Number of $20 bills: %d ", twenty); // Prints the calculated output of the variable twenty
printf("Number of $10 bills: %d ", ten); // Prints the calculated output of the variable ten
printf("Number of $5 bills: %d ", five); // Prints the calculated output of the variable five
printf("Number of $1 bills: %d ", ones); // Prints the calculated output of the variable ones
getchar();
getchar(); //keeps output window open
}
Explanation / Answer
#include #include void main() { int dllramt; int ten; int five; int twenty; int ones; clrscr(); printf("Enter Dollar Amount:"); scanf("%d",&dllramt); twenty = dllramt / 20; dllramt = dllramt % 20; ten = dllramt / 10; dllramt = dllramt % 10; five = dllramt / 5; % 5; printf("Number of $20 bills: %d ", twenty); printf("Number of $10 bills: %d ", ten); printf("Number of $5 bills: %d ", five); printf("Number of $1 bills: %d ", ones); getch(); }Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.