forked from swaaz/basicprograms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprogram.c
More file actions
45 lines (36 loc) · 839 Bytes
/
Copy pathprogram.c
File metadata and controls
45 lines (36 loc) · 839 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
40
41
42
43
44
45
// C program for printing the hollow triangle pattern
#include <stdio.h>
// Function for printing pattern
void pattern(int N)
{
int i, j, k = 0, space = 1, rows = N;
// For printing stars
for (i = rows; i >= 1; i--) {
for (j = 1; j <= i; j++) {
printf("*");
}
if (i != rows) {
// for printing space
for (k = 1; k <= space; k++) {
printf(" ");
}
// increment by 2
space = space + 2;
}
for (j = i; j >= 1; j--) {
if (j != rows)
printf("*");
}
printf("\n");
}
printf("\n");
}
// Driver code
int main()
{
// Get N
int N = 6;
// Print the pattern
pattern(N);
return 0;
}