Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a function named change() that has an integer parameter and six integer re

ID: 3675808 • Letter: W

Question

Write a function named change() that has an integer parameter and six integer reference parameters named hundreds, fifties, twenties. tens. fives, and ones The function is to consider the passed integer value as a dollar amount and convert the value into the fewest number of equivalent bills. Using the reference parameters, the function should alter the arguments in the calling function Include the function in a working program. Make sure your function is called from main() and returns a value lo main() correctly. Have main() use a cout statement to display the returned value. Test the function by passing various data to it and verifying the returned value Grading scheme: Implement the change function using correct parameters The function can correctly determine the fewest number of equivalent bills Write a main function to call the user-defined function

Explanation / Answer

#include<stdio.h>
#include<string.h>

int change( int dollar, int &hundreds, int &fifties, int &twenties, int &tens, int &fives, int &ones)
{
   int count=0;
   hundreds=dollar/100;
   count+=hundreds;
  
   dollar=dollar-(dollar/100)*100;
   fifties=dollar/50;
   count+=fifties;
  
   dollar=dollar-(dollar/50)*50;
   twenties=dollar/20;
   count+=twenties;
  
   dollar=dollar-(dollar/20)*20;
   tens=dollar/10;
   count+=tens;
  
   dollar=dollar-(dollar/10)*10;
   fives=dollar/5;
   count+=fives;

   dollar=dollar-(dollar/5)*5;
  >    count+=ones;
  
   return count;
}

int main()
{
  
    int dollar=571;
    int hundreds;
    int fifties;
    int twenties;
    int tens;
    int fives;
    int ones;
    int coin_count=change(dollar,hundreds,fifties,twenties,tens,fives,ones);
    printf("Total %d No of Changes ",coin_count);
  
    printf("Total %d Hundreds, %d Fifties , %d Twenties , %d Tens, %d Fives, %d Ones ",hundreds,fifties,twenties,tens,fives,ones);
    return 0;
}

===================================

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote