programming in c – recursive function to print star pattern 2
currently_:
_feeling: tired
_listening: high and mighty color – ichirin no hana // [gou on progressive]
_watching: naruto shippuden [153] season 7 episode 12 – following the masters shadow
_reading: help with pl/sql
_feeling: tired
_listening: high and mighty color – ichirin no hana // [gou on progressive]
_watching: naruto shippuden [153] season 7 episode 12 – following the masters shadow
_reading: help with pl/sql
-
the second star pattern is as follows:
*****
****
***
**
*
as with the previous program, this one also asks for user input as to how many lines are needed.
code:
#include <stdio.h>
#include <conio.h>
int space, count, line = 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; i > 0; i--)
printf("*");
x--;
printf("\n");
space = 0;
while(space <= line)
{
printf(" ");
space++;
}
if(line < count)
line++;
if(x > 0)
star(x);
}
_lolex.
Advertisement


No trackbacks yet.