programming in c – recursive function to print star pattern 1
currently_:
_feeling: sleepy
_listening: delays – this towns religion // [you see colours]
_watching: naruto shippuden [152] season 7 episode 11 – somber news
_reading: help with pl/sql
_feeling: sleepy
_listening: delays – this towns religion // [you see colours]
_watching: naruto shippuden [152] season 7 episode 11 – somber news
_reading: help with pl/sql
-
this program uses a recursive function to print the star pattern shown below.
*******
*****
***
*
the number of lines are to be inputted by the user.
code:
#include <stdio.h>
#include <conio.h>
int j, count, t = 0;
void star(int);
int main()
{
int x;
system("cls");
printf("enter the number of lines: ");
scanf("%d", &x);
count = x;
star(x);
getch();
}
void star(int x)
{
int i;
for(i = x + x - 1; i > 0; i--)
printf("*");
x--;
printf("\n");
j = 0;
while(j <= t)
{
printf(" ");
j++;
}
if(t < count)
t++;
if(x > 0)
star(x);
}
_lolex.
Advertisement


No trackbacks yet.