I am currently learning recursion in c language. I encountered this when trying out some stuff
#include <stdio.h>
void draw(int x)
{
if (x > 0)
{
draw(x-1);
for (int i = 0; i < x; i++)
{
printf("*");
}
printf("\n");
}
}
int main (void)
{
draw(4);
}
I expected the code to print:
****
***
**
*
Instead, it prints:
*
**
***
****
Can anyone please explain why this is the case? Thank you.