I could learn a thing or to about Recursion
I've been tasked with making a program that prints the astri "*" character in a certain pattern. It's been a little difficult for me because I don't quite understand Recursion in Cpp.
This is what my function looks like. What I was hoping for was "lines" to eventually reach 0 actiavating my else if statement but my mind set was completely wrong. Next I decided a better idea would be to activate an else if statement when lines = i. The problem is lines always equal i. I'm not asking for the anwser but I will ask anyone to explain my code in great detail so I can try better ideas.
What I'm trying to do is to get my code to print this
Quote:
*
**
***
****
****
***
**
*
Function
Code:
void printStars(int lines)
{
int i;
if (lines > 0)
{
printStars(lines - 1);
for (i = 0; i < lines; i++)
cout << "*"<<lines;
cout<< endl<< i;
}
}