Question: /*cents.c, project 5 */ #include #define QUARTER 25 #define DIME 10 #define NICKEL 5 #define PENNY 1 int main() { //initialize variables and read input

/*cents.c, project 5 */

#include #define QUARTER 25 #define DIME 10 #define NICKEL 5 #define PENNY 1

int main() { //initialize variables and read input int cents, pennies, quarters, dimes, nickels; pennies = quarters = dimes = nickels =0; printf("Enter the number of cents: "); scanf("%d", ¢s);

//check the range of the input amount if(cents< 0 || cents > 10000) printf("Invalid amount %d, Amount must be between 0 and 10000, inclusive ", cents); else { quarters = cents/QUARTER; dimes = cents%QUARTER/DIME; nickels = cents%QUARTER%DIME/NICKEL; pennies = cents%QUARTER%DIME%NICKEL;

printf("Quarters: %d ", quarters); printf("Dimes: %d ", dimes); printf("Nickels: %d ", nickels); printf("Pennies: %d ", pennies); } return 0; }

Modify cents.c (attached) that asks the user to enter a number for cents and then calculates the number of quarters, dimes, nickels, and pennies needed to add up to that amount

So it includes the following function:

 void coins(int cents, int *quarters, int *dimes, int *nickels, int *pennies); 

The function determines the smallest number of quarters, dimes, nickels, and pennies necessary to add up to the amount of cents represented by the cents parameter. The quarters parameter points to a variable in which the function will store the number of quarters required. The dimes, nickels, and pennies parameters are similar. Modify the main function so it calls coins to compute the number of quarters, dimes, nickels, and pennies. The main function should contain the printf statements that display the result.

Thank you very much in advance! I will make sure to thumbs up the answer. I appreciate it very very much

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!