forked from gouravthakur39/beginners-C-program-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Pattern1.c
66 lines (56 loc) · 721 Bytes
/
Pattern1.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
55
56
57
58
59
60
61
62
63
64
65
#include <stdio.h>
int main()
{
/** Program to print the following pattern:
*
**
***
****
*****
**/
int i,j,k;//Declaration of variable
for(i=1;i<=5;i++)
{
for(j=1;j<=i;j++)
{
printf("*");
}
printf("\n");
}
/** Program to print the following pattern:
1
123
12345
1234567
123456789
1234567
12345
123
1
**/
for (i=1;i<=5;i++)
{
for (j=i;j<5;j++)
{
printf(" ");
}
for (k=1;k<(i*2);k++)
{
printf("%d",k);
}
printf("\n");
}
for (i=4;i>=1;i--)
{
for (j=5;j>i;j--)
{
printf(" ");
}
for (k=1;k<(i*2);k++)
{
printf("%d",k);
}
printf("\n");
}
return 0;
}