Skip to content

Commit 31526ac

Browse files
Patterns and it's Algorithm
The user has to run the program and tally that to it's respective algorithm.
1 parent d71a202 commit 31526ac

File tree

1 file changed

+88
-0
lines changed

1 file changed

+88
-0
lines changed

Pattern Combos

+88
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
//Run these Pattern Program for the required output...tally it with it's respective algorithm.
2+
3+
#include <stdio.h>
4+
void main()
5+
{
6+
int i,j,k;
7+
int t=0, temp=1;
8+
//Problem:1------------------------------------1
9+
printf("Problem 1\n");
10+
for (i=0; i<5; i++)
11+
{
12+
for (j=0; j<5; j++)
13+
{
14+
printf("*");
15+
}
16+
printf("\n");
17+
}
18+
printf("\n\n");
19+
//Problem:2-------------------------------------2
20+
printf("Problem 2\n");
21+
for (i=1; i<=5; i++)
22+
{
23+
for (j=5; j>=i; j--)
24+
{
25+
printf(" ");
26+
}
27+
for (k=1; k<=i; k++)
28+
{
29+
printf("*");
30+
}
31+
printf("\n");
32+
}
33+
printf("\n\n");
34+
//Problem:3--------------------------------------3
35+
printf("Problem 3\n");
36+
for (i=0; i<5; i++)
37+
{
38+
for (j=0; j<=i; j++)
39+
{
40+
printf("*");
41+
}
42+
printf("\n");
43+
}
44+
printf("\n\n");
45+
//Problem:4-------------------------------------4
46+
printf("Problem 4\n");
47+
for (i=5; i>=1; i--)
48+
{
49+
for (k=temp; k>=0; k--)
50+
{
51+
printf(" ");
52+
}
53+
for (j=i; j>=1; j--)
54+
{
55+
printf("*");
56+
}
57+
temp = temp + 1;
58+
printf("\n");
59+
}
60+
printf("\n\n");
61+
//Problem:5--------------------------------------5
62+
printf("Problem 5\n");
63+
for (i=5; i>=1; i--)
64+
{
65+
for (j=1; j<=i; j++)
66+
{
67+
printf("*");
68+
}
69+
printf("\n");
70+
}
71+
printf("\n\n");
72+
//Problem:6--------------------------------------6
73+
printf("Problem 6\n");
74+
for (i=1; i<=5; i++)
75+
{printf(" ");
76+
for (k=t; k<5; k++)
77+
{
78+
printf(" ");
79+
}
80+
for (j=0; j< i; j++)
81+
{
82+
printf(" * ");
83+
t = t + 1;
84+
}
85+
printf("\n");
86+
}
87+
88+
}

0 commit comments

Comments
 (0)