Question
Function Practice Write a function named exchange that is used to convert some amount of mixed change to the equivalent number of cents. The function
Function Practice
Write a function named exchange that is used to convert some amount of mixed change to the equivalent number of cents. The function takes 5 integer parameters representing the number of dollars, quarters, dimes, nickels, and pennies, and returns the integer total value of all the change in cents.
Write the C statements that could be added to the main function to define data needed for the previous problem. Call the exchange function, passing the data as parameters. Display the returned result. Additional question: could a version of this function be written that does the opposite (takes some number of cents and returns the number of dollars, quarters, dimes, etc.)? Explain your answer.
Define a C function named computePay that calculates and returns the total weekly pay for an individual. This function has two input parameters, both double: the total number of hours worked by the person that week (lets call that h), and the base pay rate per hour (lets call that r). The total pay for the week is calculated as follows:
If total hours h is less than 0 or more than 100, that is clearly a data entry error, and the function should return a value of 0.0.
The individual is paid the base hourly rate, r, for each of the first 40 hours.
The individual is paid 1.5 times the base rate for all hours above 40.
Which of the following would be an appropriate prototype statement for this function?
double computePay (h,r);
int computePay (h, r, p);
void computePay (double h, double r);
int computePay (double a, double b, int c );
double computePay (double a, double b);
Write the C statements that could be added to the main function to declare two variables and assign to them the values of some number of hours worked and the base hourly pay rate for an individual. Call the computePay function, passing the variables as arguments. (Walk through your function code and make sure it works correctly for example values of 42 hours and 25 hours, as well as a value that would be considered an error.)
Write a function named countBlanks that counts and returns the integer number of blank spaces that appear in a string provided as a parameter. (Recall that a blank space is a character: )
Write the C statements that could be added to the main function to define a string named sentence that could be used for the previous problem, using your choice of words. Call the function countBlanks, passing sentence as a parameter. Display the returned result.
Define a function named biggest that locates and returns the largest value in a 1-d array of floating point values
that is provided as a parameter.
Write the C statements that could be added to the main function to declare a 1-d array of floating point values named miles of length 4 that could be used for the previous problem. Initialize the array using your choice of values. Call the function biggest, passing the array as a parameter and display the returned result.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started