0

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
0

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.

0

#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();
}

0

wad about this?
*
* *
* * *
* * * *
* * * *
* * *
* *
*

This topic has been dead for over six months. 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.