We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 6be80a8 commit 94468fdCopy full SHA for 94468fd
Star Pattern
@@ -0,0 +1,30 @@
1
+#include <stdio.h>
2
+int main(void) {
3
+ int n;
4
+ printf("Enter the number of rows\n");
5
+ scanf("%d",&n);
6
+ int spaces=n-1;
7
+ int stars=1;
8
+ for(int i=1;i<=n;i++)
9
+ {
10
+ for(int j=1;j<=spaces;j++)
11
12
+ printf(" ");
13
+ }
14
+ for(int k=1;k<=stars;k++)
15
16
+ printf("*");
17
18
+ if(spaces>i)
19
20
+ spaces=spaces-1;
21
+ stars=stars+2;
22
23
+ if(spaces<i)
24
25
+ spaces=spaces+1;
26
+ stars=stars-2;
27
28
+ printf("\n");
29
30
+ return 0;}
0 commit comments