File tree Expand file tree Collapse file tree 1 file changed +69
-0
lines changed Expand file tree Collapse file tree 1 file changed +69
-0
lines changed Original file line number Diff line number Diff line change
1
+ /*
2
+
3
+ Program in C to print the Hollow Number Diamond Pattern
4
+
5
+ Sample Input:
6
+
7
+ 4
8
+
9
+ Sample Output:
10
+
11
+ *
12
+ * *
13
+ * *
14
+ * *
15
+ * *
16
+ * *
17
+ * *
18
+ * *
19
+ *
20
+
21
+ --------------------------------
22
+
23
+ */
24
+ #include <stdio.h>
25
+ int main ()
26
+ {
27
+ printf ("Enter the number of rows to show the star pattern: " );
28
+ int n , x , y , s = 1 , k ;
29
+ scanf ("%d" ,& n );
30
+ for (x = 0 ; x <= n ; x ++ )
31
+ {
32
+ for (y = n ; y > x ; y -- )
33
+ {
34
+ printf (" " );
35
+ }
36
+ printf ("*" );
37
+ if (x > 0 )
38
+ {
39
+ for (k = 1 ; k <= s ; k ++ )
40
+ {
41
+ printf (" " );
42
+ }
43
+ s += 2 ;
44
+ printf ("*" );
45
+ }
46
+ printf ("\n" );
47
+ }
48
+ s -= 4 ;
49
+ for (x = 0 ; x <= n - 1 ; x ++ )
50
+ {
51
+ for (y = 0 ; y <= x ; y ++ )
52
+ {
53
+ printf (" " );
54
+ }
55
+ printf ("*" );
56
+ for (k = 1 ; k <= s ; k ++ )
57
+ {
58
+ printf (" " );
59
+ }
60
+ s -= 2 ;
61
+ if (x != n - 1 )
62
+ {
63
+ printf ("*" );
64
+ }
65
+ //ending line after each row
66
+ printf ("\n" );
67
+ }
68
+ return 0 ;
69
+ }
You can’t perform that action at this time.
0 commit comments