Oct 24, 2018 at 12:52am
pls, i just need help making this a returning function instead of void -> int and retunr the squared.
1 2 3 4 5 6 7 8 9
|
void squared(int sq)
{
if(sq != 1)
squared(sq - 1); //recursive call for squared integers from 1 to integer
cout << setw(3) << sq << setw(12) << sq * sq << endl;
}
|
Last edited on Oct 24, 2018 at 12:52am
Oct 24, 2018 at 3:49am
return sq*sq
would return you the square of the number. What are you trying to achieve?