0

I have a recursive function squares that receives a positive integer n and prints out the first n perfect squares in descending order. Can anyone tell me if this is correct and if not please help.

squares(int n)
{
if( n== 1 )
return 1;

else
return squares ) n * n );
}
2
Contributors
2
Replies
3
Views
9 Years
Discussion Span
Last Post by buddy1
0
void squares(int n)
{
    if( n== 1 ) 
        cout << 1 ;
    else
    {
         cout << n*n << " " ;//swap lines 7 & 8 for ascending order
         squares ( n- 1 );
    }
}
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.