-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChristmas tree.c
More file actions
39 lines (38 loc) · 922 Bytes
/
Christmas tree.c
File metadata and controls
39 lines (38 loc) · 922 Bytes
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
#include <stdio.h>
int main()
{
int width, height, space, i, j, k, n = 1;
printf("Please Enter Chirstmas Tree Width & Height = ");
scanf("%d %d", &width, &height);
space = width * height;
printf("Printing Chirstmas Tree Pattern of Stars\n");
for (int x = 1; x <= height; x++)
{
for (i = n; i <= width; i++)
{
for (j = space; j >= i; j--)
{
printf(" ");
}
for (k = 1; k <= i; k++)
{
printf("* ");
}
printf("\n");
}
n = n + 2;
width = width + 2;
}
for (i = 1; i <= height - 1; i++)
{
for (j = space - 3; j >= 0; j--)
{
printf(" ");
}
for (k = 1; k <= height - 1; k++)
{
printf("* ");
}
printf("\n");
}
}