There was an error while loading. Please reload this page.
1 parent b9735e2 commit c7dc889Copy full SHA for c7dc889
triangle_with_border_and_hash.c
@@ -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