i just got an exercise i am asked to do and i have no idea what to do.
I am asked to use recursive to print a pattern without using loop:
*
**
***
****
****
***
**
*

And also :
****
***
**
*
**
***
****

Any help is very much appreciated.

3
Contributors
3
Replies
5
Views
7 Years
Discussion Span
Last Post by knnccb

i just got an exercise i am asked to do and i have no idea what to do.
I am asked to use recursive to print a pattern without using loop:
*
**
***
****
****
***
**
*

And also :
****
***
**
*
**
***
****

Any help is very much appreciated.

Do you know what recursion is? I mean can you write a recursive function? Your program's solution depends on that.You will write a recursive function print and play with its parameters.

#include<stdio.h>
#include<conio.h>
void put(int n)
{
if(n>0)
{
put(n-1);
printf("*");
}
}
void disp1(int n)
{if(n>0)
{
disp1(n-1);
put(n);
}
printf("\n");
}
void disp2(int n)
{
if(n>0)
{

put(n);
printf("\n");
disp2(n-1);

}
}

void star(int n)
{
disp1(n);
disp2(n);
}
void main()
{
int xy=4;
clrscr();
star(xy);
getch();
}