(TCO 5) Write a function that converts an input of some integer number of nickel
ID: 1925731 • Letter: #
Question
(TCO 5) Write a function that converts an input of some integer number of nickels into outputs of integer numbers of dollars, quarters, and nickels. Do not write a main function. Your function does not do cin or cout. Your function will have four parameters. Make sure you use appropriate parameter passing techniques! Your function will be a void function. There are 5 nickels in a quarter, and 20 nickels in a dollar. For example, if the total number of nickels input is 27, the results are 1 dollar, 1 quarter, and 2 nickels.
Explanation / Answer
//a is input no. of nickels
//d,q&n are output no. of dollars, quarters and nickels
void funct(int a,int &n,int &q,int &d)
{
d = a/20;
q = (a-(d*20))/5;
n = a-(d*20)-(q*5);
return;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.