Modify the program below by adding the following function: void pay_amount(int d
ID: 1798026 • Letter: M
Question
Modify the program below by adding the following function:void pay_amount(int dollars, int*twenties, int*tens, int*fives, int*ones)
Program below:
// 1/28/2012 // Asks user for dollar amount and breaks it down into how many 20s,10s,5s,1s you need. #include <stdio.h> void int main(void) { int dllramt; int *tenn; int *fives; int *twentyy; int *one; //Initializes the variables printf( "Enter Dollar Amount:"); //ask user for dallar amount pay_amount(dllramt, twentyy, tenn, fives, one); printf( "Number of $20 bills: %d ", twentyy); // Prints the calculated output of the variable twenty printf( "Number of $10 bills: %d ", tenn); // Prints the calculated output of the variable ten printf( "Number of $5 bills: %d ", fives); // Prints the calculated output of the variable five printf( "Number of $1 bills: %d ", one); // Prints the calculated output of the variable ones getchar(); getchar(); //keeps output window open }
Modify the program below by adding the following function:
void pay_amount(int dollars, int*twenties, int*tens, int*fives, int*ones)
Program below:
// 1/28/2012 // Asks user for dollar amount and breaks it down into how many 20s,10s,5s,1s you need.
// 1/28/2012 // Asks user for dollar amount and breaks it down into how many 20s,10s,5s,1s you need. // 1/28/2012 // Asks user for dollar amount and breaks it down into how many 20s,10s,5s,1s you need. // 1/28/2012 // Asks user for dollar amount and breaks it down into how many 20s,10s,5s,1s you need. // 1/28/2012 // Asks user for dollar amount and breaks it down into how many 20s,10s,5s,1s you need. #include <stdio.h> void int main(void) { int dllramt; int *tenn; int *fives; int *twentyy; int *one; //Initializes the variables printf( "Enter Dollar Amount:"); //ask user for dallar amount pay_amount(dllramt, twentyy, tenn, fives, one); printf( "Number of $20 bills: %d ", twentyy); // Prints the calculated output of the variable twenty printf( "Number of $10 bills: %d ", tenn); // Prints the calculated output of the variable ten printf( "Number of $5 bills: %d ", fives); // Prints the calculated output of the variable five printf( "Number of $1 bills: %d ", one); // Prints the calculated output of the variable ones getchar(); getchar(); //keeps output window open }
#include #include #include #include #include <stdio.h> void int main(void) { int dllramt; int *tenn; int *fives; int *twentyy; int *one; //Initializes the variables printf( "Enter Dollar Amount:"); //ask user for dallar amount pay_amount(dllramt, twentyy, tenn, fives, one); printf( "Number of $20 bills: %d ", twentyy); // Prints the calculated output of the variable twenty printf( "Number of $10 bills: %d ", tenn); // Prints the calculated output of the variable ten printf( "Number of $5 bills: %d ", fives); // Prints the calculated output of the variable five printf( "Number of $1 bills: %d ", one); // Prints the calculated output of the variable ones getchar(); getchar(); //keeps output window open <stdio.h> void void void void int main(void) { { { int dllramt; int *tenn; int *fives; int *twentyy; int *one; //Initializes the variables printf( printf( printf( "Enter Dollar Amount:"); //ask user for dallar amount pay_amount(dllramt, twentyy, tenn, fives, one); printf( pay_amount(dllramt, twentyy, tenn, fives, one); printf( pay_amount(dllramt, twentyy, tenn, fives, one); printf( "Number of $20 bills: %d ", twentyy); // Prints the calculated output of the variable twenty printf( printf( printf( "Number of $10 bills: %d ", tenn); // Prints the calculated output of the variable ten printf( printf( printf( "Number of $5 bills: %d ", fives); // Prints the calculated output of the variable five printf( printf( printf( "Number of $1 bills: %d ", one); // Prints the calculated output of the variable ones getchar(); getchar(); getchar(); getchar(); getchar(); getchar(); //keeps output window open } } } }
Explanation / Answer
// 1/28/2012 // Asks user for dollar amount and breaks it down into how many 20s,10s,5s,1s you need. #include void pay_amount(int dollars, int*twenties, int*tens, int*fives, int*ones) void int main(void) { int dllramt; int *tenn; int *fives; int *twentyy; int *one; //Initializes the variables printf( "Enter Dollar Amount:"); //ask user for dallar amount pay_amount(dllramt, twentyy, tenn, fives, one); printf( "Number of $20 bills: %d ", twentyy); // Prints the calculated output of the variable twenty printf( "Number of $10 bills: %d ", tenn); // Prints the calculated output of the variable ten printf( "Number of $5 bills: %d ", fives); // Prints the calculated output of the variable five printf( "Number of $1 bills: %d ", one); // Prints the calculated output of the variable ones getchar(); getchar(); //keeps output window open } void pay_amount(int dollars, int*twenties, int*tens, int*fives, int*ones) { if(dollars %20 == 0) { *twenties = dollars/20; dollars = dollars%20; } else if(dollars % 10 == 0) { *tens = dollars/10; dollars = dollars%10; } else if( dollars % 5 == 0) { *fives = dollars/5; dollars = dollars%5; } else { *ones = dollars/1; } }Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.