File tree Expand file tree Collapse file tree 1 file changed +50
-0
lines changed
Codechef Problems/DSA Learning Series Expand file tree Collapse file tree 1 file changed +50
-0
lines changed Original file line number Diff line number Diff line change
1
+ /* You're given a number N. Print the first N lines of the below-given pattern.
2
+
3
+ *
4
+ **
5
+ ***
6
+ ****
7
+ *****
8
+ Input:
9
+ First-line will contain the number N.
10
+ Output:
11
+ Print the first N lines of the given pattern.
12
+
13
+ Constraints
14
+ 1≤N≤200
15
+ Sample Input 1:
16
+ 4
17
+ Sample Output 1:
18
+ *
19
+ **
20
+ ***
21
+ ****
22
+ Sample Input 2:
23
+ 2
24
+ Sample Output 2:
25
+ *
26
+ **
27
+ EXPLANATION:
28
+ In the first example, we'll print the first 4 lines of the given pattern.
29
+ In the second example, we'll print the first 2 lines of the given pattern */
30
+
31
+
32
+ #include <stdio.h>
33
+
34
+ int main (void ) {
35
+
36
+ int t ;
37
+ scanf ("%d" ,& t );
38
+
39
+ for (int i = 1 ;i <=t ;i ++ )
40
+ {
41
+ for (int j = t ;j > i ;j -- )
42
+ printf (" " );
43
+ for (int k = 1 ;k <=i ;k ++ )
44
+ printf ("*" );
45
+ printf ("\n" );
46
+ }
47
+
48
+
49
+ return 0 ;
50
+ }
You can’t perform that action at this time.
0 commit comments