-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
367 lines (345 loc) · 9.89 KB
/
main.cpp
File metadata and controls
367 lines (345 loc) · 9.89 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
// Welcome to project work of computer science
/*This project is based on the concept of looping*/
#include <iostream>
using namespace std;
int main() //main function is start
{
int upyra(); //prototype of uppyra function
int dowpyr(); //prototype of dowpyr function
int dia(); //prototype of dia function
int star(); //prototype of star function
int design(); //prototype of design function
int a,b;
cout<<"\t\tWELCOME TO PROJECT WORK OF COMPUTER SCIENCE\n";
for(a=1;a<=80;a++)
cout<<"-";
cout<<"\nThis project is based on the concept of looping. \nIn this project different patterns are drawn according to situation (given downward).\nTo print choose option:\n";
for(a=1;a<=80;a++)
cout<<"-";
cout<<"\n 1.To print pattern of upward pyramid\n\
2.To print pattern of downward pyramid\n\
3.To print pattern of diamond\n\
4 To print pattern of star\n\
5.To print beautiful pattern\n\
6.To exit\n";
for(a=1;a<=80;a++)
cout<<"-";
start:
cout<<"\nEnter the option chosen by you: ";
char ch;
cin>>b;
cout<<"\n";
switch (b)
{
case 1 : upyra(); //calling upyra function
break;
case 2 : dowpyr(); //calling dowpyr function
break;
case 3 : dia(); //calling dia function
break;
case 4 : star(); //calling star function
break;
case 5 : design(); //calling design function
break;
case 6 : cout<<"\n\t\tTHANKS FOR ACCESSING MY PROJECT";
break;
default: cout<<"Wrong value!!!!!!!!!!\n";
break;
}
cout<<"\n";
if(b==6)
goto bot;
cout<<"Do you want to continue?\nEnter (y or n):\t";
top:
cin>>ch;
if(ch=='y'||ch=='Y')
goto start;
else
if(ch=='n'||ch=='N')
cout<<"\n\t\tTHANKS FOR ACCESSING MY PROJECT";
else
cout<<"Wrong value!!!!!!!\nType (y or n):";
goto top;
bot:
return 0;
} //main function is end here
int upyra() //declaration of function upyra
{
for(int z=1;z<=5;z++) //first main loop of upyra is start
{
for(int a=5;a>=z;a--)
cout<<" ";
for(int b=1;b<=z;b++)
cout<<"* ";
for(int c=2;c<=z;c++)
cout<<"* ";
for(int d=5;d>=z;d--)
cout<<" ";
for(int e=1;e<=z;e++)
cout<<" ";
for(int f=5;f>=z;f--)
cout<<" ";
for(int g=5;g>=z;g--)
cout<<" ";
for(int h=1;h<=z;h++)
if(h==1||z==5)
cout<<"* ";
else
cout<<" ";
for(int i=2;i<=z;i++)
if(i==1||i==z||z==5)
cout<<"* ";
else
cout<<" ";
cout<<"\n";
} //first loop of upyra end
return 0;
}
int dowpyr() //declaration of function dowpyr
{
for(int z=1;z<=5;z++) //first main loop of dowpyr start
{
for(int a=1;a<=z;a++)
cout<<" ";
for(int b=5;b>=z;b--)
cout<<"* ";
for(int c=4;c>=z;c--)
cout<<"* ";
for(int d=1;d<=z;d++)
cout<<" ";
for(int e=5;e>=z;e--)
cout<<" ";
for(int f=1;f<=z;f++)
cout<<" ";
for(int g=1;g<=z;g++)
cout<<" ";
for(int h=5;h>=z;h--)
if(h==5||z==1)
cout<<"* ";
else
cout<<" ";
for(int i=4;i>=z;i--)
if(i==5||i==z||z==1)
cout<<"* ";
else
cout<<" ";
cout<<"\n";
} //first main loop of dowpyr end
return 0;
}
int dia() //declaration of function dia
{
for(int z=1;z<=5;z++) //first main loop of dia start
{
for(int a=5;a>=z;a--)
cout<<" ";
for(int b=1;b<=z;b++)
cout<<"* ";
for(int c=2;c<=z;c++)
cout<<"* ";
for(int d=5;d>=z;d--)
cout<<" ";
for(int e=1;e<=z;e++)
cout<<" ";
for(int f=5;f>=z;f--)
cout<<" ";
for(int g=5;g>=z;g--)
cout<<" ";
for(int h=1;h<=z;h++)
if(h==1)
cout<<"* ";
else
cout<<" ";
for(int i=2;i<=z;i++)
if(i==1||i==z)
cout<<"* ";
else
cout<<" ";
cout<<"\n";
} //first main loop of dia end
for(int y=2;y<=5;y++) //second main loop of dia start
{
for(int a=1;a<=y;a++)
cout<<" ";
for(int b=5;b>=y;b--)
cout<<"* ";
for(int c=4;c>=y;c--)
cout<<"* ";
for(int d=1;d<=y;d++)
cout<<" ";
for(int e=1;e<=y;e++)
cout<<" ";
for(int f=5;f>=y;f--)
cout<<" ";
for(int g=1;g<=y;g++)
cout<<" ";
for(int h=5;h>=y;h--)
if(h==5||h==1)
cout<<"* ";
else
cout<<" ";
for(int i=4;i>=y;i--)
if(i==5||i==y)
cout<<"* ";
else
cout<<" ";
cout<<"\n";
} //second main loop of dia end
return 0;
}
int star() //declaration of function star
{
for (int z=1;z<=3;z++) //first main loop of star start
{
cout<<"\t\t";
for(int a=3;a>=z;a--)
cout<<" ";
for(int b=1;b<=z;b++)
cout<<" ";
for(int c=3;c>=z;c--)
cout<<" ";
for(int d=2;d<=z;d++)
cout<<"* ";
for(int e=1;e<=z;e++)
cout<<"* ";
for(int f=3;f>=z;f--)
cout<<" ";
cout<<"\n";
} //first main loop of star end
for (int y=1;y<=3;y++) //second main loop of star start
{
cout<<"\t\t";
for(int a=1;a<=y;a++)
cout<<" ";
for(int b=3;b>=y;b--)
cout<<"* ";
for(int c=3;c>=y;c--)
cout<<"* ";
for(int d=1;d<=y;d++)
cout<<"@ ";
for(int e=2;e<=y;e++)
cout<<"@ ";
for(int f=3;f>=y;f--)
cout<<"* ";
for(int g=3;g>=y;g--)
cout<<"* ";
for(int h=1;h<=y;h++)
cout<<" ";
cout<<"\n";
} //second main loop of star end
for (int x=1;x<=3;x++) //third main loop of star start
{
cout<<"\t\t";
for(int a=3;a>=x;a--)
cout<<" ";
for(int b=1;b<=x;b++)
cout<<"* ";
for(int c=1;c<=x;c++)
cout<<"* ";
for(int d=3;d>=x;d--)
cout<<"@ ";
for(int e=2;e>=x;e--)
cout<<"@ ";
for(int f=1;f<=x;f++)
cout<<"* ";
for(int g=1;g<=x;g++)
cout<<"* ";
for(int h=3;h>=x;h--)
cout<<" ";
cout<<"\n";
} //third main loop of star end
for (int w=1;w<=3;w++) //fourth main loop of star start
{
cout<<"\t\t";
for(int a=3;a>=w;a--)
cout<<" ";
for(int b=1;b<=w;b++)
cout<<" ";
for(int c=1;c<=w;c++)
cout<<" ";
for(int d=3;d>=w;d--)
cout<<"* ";
for(int e=2;e>=w;e--)
cout<<"* ";
for(int f=1;f<=w;f++)
cout<<" ";
cout<<"\n";
} //fourth main loop of start end
return 0;
}
int design() //declaration of function design
{
for(int z=1;z<=5;z++) //first main loop of design start
{
for(int a=5;a>=z;a--)
cout<<" ";
for(int b=1;b<=z;b++)
if(b==1||z==5||b==z)
cout<<"@ ";
else
cout<<"* ";
for(int c=2;c<=z;c++)
if(c==1||c==z||z==5)
cout<<"@ ";
else
cout<<"* ";
for(int d=5;d>=z;d--)
cout<<" ";
for(int e=1;e<=z;e++)
cout<<" ";
for(int f=5;f>=z;f--)
cout<<" ";
for(int g=5;g>=z;g--)
cout<<" ";
for(int h=1;h<=z;h++)
if(h==1||h==5)
cout<<"@ ";
else
cout<<"* ";
for(int i=2;i<=z;i++)
if(i==1||i==z)
cout<<"@ ";
else
cout<<"* ";
for(int j=5;j>=z;j--)
cout<<" ";
cout<<"\n";
} //first main loop of design end
for(int y=2;y<=5;y++) //second main loop of design start
{
for(int a=1;a<=y;a++)
cout<<" ";
for(int b=5;b>=y;b--)
if(b==5||b==1||b==y)
cout<<"@ ";
else
cout<<"* ";
for(int c=4;c>=y;c--)
if(c==1||c==y)
cout<<"@ ";
else
cout<<"* ";
for(int d=1;d<=y;d++)
cout<<" ";
for(int e=5;e>=y;e--)
cout<<" ";
for(int f=1;f<=y;f++)
cout<<" ";
for(int g=1;g<=y;g++)
cout<<" ";
for(int h=5;h>=y;h--)
if(h==5||h==1)
cout<<"@ ";
else
cout<<"* ";
for(int i=4;i>=y;i--)
if(i==5||i==y)
cout<<"@ ";
else
cout<<"* ";
for(int j=1;j<=y;j++)
cout<<" ";
cout<<"\n";
} //second main loop of design end
return 0;
}