Asterisk Tree problem in Turbo C

Here's my code below and the outputs. I got a little problem with figure 3-6 on how to do it. Is there

Output --> http://i168.photobucket.com/albums/u162/SHENGTON/untitled-2.jpg

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#include<stdio.h>
#include<conio.h>
void fig1(void);
void fig2(void);
void fig3(void);
void fig4(void);
void fig5(void);
void fig6(void);
int main()
{
 int cho, i;
 do{
  printf("[1] Figure 1\n");
  printf("[2] Figure 2\n");
  printf("[3] Figure 3\n");
  printf("[4] Figure 4\n");
  printf("[5] Figure 5\n");
  printf("[6] Figure 6\n");
  printf("[7] Exit\n\n");
  printf("Enter your choice:");
  scanf("%d",&cho);
  i = getchar();
  if(cho==1)
  {
   fig1();
  }
  else if(cho==2)
  {
   fig2();
  }
  else if(cho==3)
  {
   fig3();
  }
  else if(cho==4)
  {
   fig4();
  }
  else if(cho==5)
  {
   fig5();
  }
  else if(cho==6)
  {
   fig6();
  }
 }while(cho != 7);
  printf("\n\n\t\t\t    press enter when ready");
  i = getchar();
  ++i;
  clrscr();
  return 0;
}

void fig1(void)
{
 int i,j,k;
 clrscr();
 printf("Input a number:");
 scanf("%d",&k);
 for(i=k;i>=1;i--)
 {
  for(j=k;j>=i;j--)
  {
   printf("* ");
  }
  printf("\n\n");
 }
}

void fig2(void)
{
 int i,j,k;
 clrscr();
 printf("Input a number:");
 scanf("%d",&k);
 clrscr();
 for(i=1;i<=k;i++)
 {
  for(j=k;j>=i;j--)
  {
   printf("* ");
  }
  printf("\n\n");
 }
}

void fig3(void)
{
 int i,j,k,l;
 clrscr();
 printf("Input a number:");
 scanf("%d",&k);
 for(i=k;i>=1;i--)
 {
  for(j=k;j>=i;j--)
  {
   printf("* ");
  }
  for(l=0;l<=k;l++)
  {
   printf(" ");
  }
  printf("\n\n");
 }
}

void fig4(void)
{
 int i,j;
 clrscr();
 for(i=1;i<=5;i++)
 {
  for(j=5;j>=i;j--)
  {
   printf("* ");
  }
  printf("\n\n");
 }
}

void fig5(void)
{
 int i,j;
 clrscr();
 for(i=1;i<=5;i++)
 {
  for(j=5;j>=i;j--)
  {
   printf("* ");
  }
  printf("\n\n");
 }
}
void fig6(void)
{
 int i,j;
 clrscr();
 for(i=1;i<=5;i++)
 {
  for(j=5;j>=i;j--)
  {
   printf("* ");
  }
  printf("\n\n");
 }
}
Topic archived. No new replies allowed.