-
Notifications
You must be signed in to change notification settings - Fork 0
/
*_upstairs.c
54 lines (45 loc) · 845 Bytes
/
*_upstairs.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
43
44
45
46
47
48
49
50
51
52
53
54
#include <stdio.h>
#include <stdlib.h>
/*
n=5 will print
* *
* *
* * * *
* * * *
* * * * * *
* * * * * *
* * * * * * * *
* * * * * * * *
* * * * * * * * * *
* * * * * * * * * *
*/
int main()
{
int s,n,k,i,g,j;
printf("Enter number of steps : ");
scanf("%d",&s);
n=s*2;
printf("\n\n");
for(i=1; i<=n; i++)
{
k = (i%2==1) ? i+1 : i ;// k is set to i+1 for every i and i+1
for(g=1;g<=n-k;g++)
{
if(g==n||g==n-1)
{
printf("");
}
else
{
printf(" ");
}
printf(" ");
}
for(j=1; j<=k; j++)
{
printf("* ");
}
printf("\n");
}
return 0;
}