Skip to content

Commit c7dc889

Browse files
committed
Create triangle_with_border_and_hash.c
1 parent b9735e2 commit c7dc889

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

triangle_with_border_and_hash.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
Problem Statement: Create a C program to print a triangle pattern of
3+
asterisks (*) and hashes (#) where the boundary elements are * and
4+
the inner elements are #, except the last row which is fully made of *.
5+
*/
6+
7+
#include<stdio.h>
8+
9+
int main() {
10+
int i, j, n;
11+
12+
i = n;
13+
14+
printf("Enter the value for n: ");
15+
scanf("%d", &n);
16+
17+
for ( i = 0; i < n; i++)
18+
{
19+
for ( j = 0; j <= i; j++){
20+
if (j == 0 || i == j || i == n-1)
21+
{
22+
printf(" * ");
23+
}
24+
else
25+
{
26+
printf(" # ");
27+
}
28+
29+
}
30+
printf("\n");
31+
}
32+
return 0;
33+
}

0 commit comments

Comments
 (0)