

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


Take Home: Quiz 5 (15 pts) – Pointers/Output Parameters Using Canvas https://canvas.wsu.edu/, please submit your solution to the correct quiz folder. Your solution should be a .pdf file with the name
link in the main left menu bar. Navigate to the correct quiz submission folder. Click the “Start Assignment” button. Click the “Upload File” button. Choose the appropriate .pdf file with your solution. Finally, click the “Submit Assignment” button. NOTE: The use of gen AI is forbidden for quizzes.
bills dispensed include: 100’s, 50’s, 20’s, and 10’s. The number of each bill to dispense should be stored indirectly through the pointers: hundreds_ptr, fifties_ptr, twenties_ptr, and tens_ptr. If the withdrawal_amount exceeds the balance, then the number of each bill to dispense should be set to 0, and 0 should be returned. If the withdrawal_amount is less than or equal to the balance, then the number of each bill to dispense should be calculated, and 1 should be returned. The function header has been provided for you. // precondition: withdrawal amount must be a multiple of 10 // return: 1 if the balance >= withdrawal_amount; 0 otherwise int dispense_bills(double balance, double withdrawal_amount, int *hundreds_ptr, int *fifties_ptr, int *twenties_ptr, int *tens_ptr) { if (withdrawal_amount > balance) { *hundreds_ptr = 0; *fifties_ptr = 0; *twenties_ptr = 0; *tens_ptr = 0; return 0; } int amount = (int)withdrawal_amount; *hundreds_ptr = amount / 100; amount %= 100; *fifties_ptr = amount / 50; amount %= 50; *twenties_ptr = amount / 20; amount %= 20; *tens_ptr = amount / 10; return 1; }