# Can you return multiple values in a C++ function?

I have to use recursion to figure out how many 2's and 5's it will take to make an integer greater than 4. For example with the integer 14, you need two 2's and two 5's. For 13, you need four 2's and one 5.
It basically works like this. As you count up, if there is more than two 2's then...
show more
I have to use recursion to figure out how many 2's and 5's it will take to make an integer greater than 4. For example with the integer 14, you need two 2's and two 5's. For 13, you need four 2's and one 5.

It basically works like this. As you count up, if there is more than two 2's then you take away two 2's and add a 5, otherwise you minus one away from the 5's and add three 2's. I am asked to do this in a recursive function but i am unsure as to how. The inputs are the integer wanted and I assume the 2's and 5's. So i think it is

fcnName(n,two,five)

{

if(n==4)

return two 2's and zero 5's

unsure of what else to put in here

}

It basically works like this. As you count up, if there is more than two 2's then you take away two 2's and add a 5, otherwise you minus one away from the 5's and add three 2's. I am asked to do this in a recursive function but i am unsure as to how. The inputs are the integer wanted and I assume the 2's and 5's. So i think it is

fcnName(n,two,five)

{

if(n==4)

return two 2's and zero 5's

unsure of what else to put in here

}

Follow

4 answers
4

Are you sure you want to delete this answer?