-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathFullPyramid.c
More file actions
57 lines (52 loc) · 788 Bytes
/
Copy pathFullPyramid.c
File metadata and controls
57 lines (52 loc) · 788 Bytes
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include<stdio.h>
#define MAX 5 // setting variable MAX to 5
int main()
{
int i,j; // declaration of variables
int space=4;
/*run loop (parent loop) till number of rows*/
for(i=0;i< MAX;i++)
{
/*loop for initially space, before star printing*/
for(j=0;j< space;j++)
{
printf(" ");
}
for(j=0;j<=i;j++)
{
printf("* ");
}
printf("\n");
space--;
}
/*repeat it again*/
space=0;
/*run loop (parent loop) till number of rows*/
for(i=MAX;i>0;i--)
{
/*loop for initially space, before star printing*/
for(j=0;j< space;j++)
{
printf(" ");
}
for(j=0;j< i;j++)
{
printf("* ");
}
printf("\n");
space++;
}
return 0;
}
/* Output Example
*
* *
* * *
* * * *
* * * * *
* * * * *
* * * *
* * *
* *
*
*/