-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathpattern3.c
42 lines (37 loc) · 849 Bytes
/
pattern3.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*Pattern3*/
/*
for eg.for 5 rows
*
* *
* * *
* * * *
* * * * *
* * * *
* * *
* *
*
*/
#include <stdio.h>
void main()
{
int row, column, no_of_rows;
printf("Enter the no. of rows: ");
scanf("%d", &no_of_rows);
/*Combining pattern1 and pattern2 and making small changes gives me this pattern*/
for (row = 1; row <= no_of_rows; row++)
{
for (column = 1; column <= row; column++)
{
printf("* ");
}
printf("\n");
}
for (row = no_of_rows - 1; row >= 1; row--) /*Notice that I have started from no_of_rows-1 because without that intialization, the pattern looks unsymmetrical at the centre row*/
{
for (column = 1; column <= row; column++)
{
printf("* ");
}
printf("\n");
}
}