-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathday6.cpp
299 lines (272 loc) · 4.64 KB
/
day6.cpp
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
#include<iostream>
using namespace std;
int main()
{
while(true)
{
int number;
cout<<"Enter the number:"<<endl;
cin>>number;
if(number ==-1)
{
break;
}
}
cout<<endl;
cout<<"QUESTION:Question2: print the multiple of first 5 which is also multiple of 7"<<endl;
int i=5;
while(true)
{
if(i%7==0)
{
cout<<"The value that meet the requirements: "<<i<<endl;
break;
}
i+=5; //increament of 5
}
cout<<endl;
cout<<"Question2: now make the continue statment which ignore 3 in the whole loop"<<endl;
for (int i=1;i<=5;i++)
{
if(i==3)
{
continue; //3 2ill skip from the answer
}
cout<<i<<" ";
}
cout<<endl;
cout<<"Question3: print the number betwwen 1 to 50 except the number which is number%3==0"<<endl;
for(int i=1;i<=50;i++)
{
if (i%3==0)
{
continue;
}
else
{
cout<<i<<" ";
}
}
cout<<endl;
cout<<"****\n****\n****\n****\nprint this type of pattren??"<<endl;
cout<<endl;
for (int i=1;i<=4;i++)
{
for(int j=1;j<=4;j++)
{
cout<<"*";
}
cout<<endl;
}
// cout<<endl;
// cout<<"Print the hollogram pattren"<<endl;
// int n,m;
// cin>>n>>m;
// for (int i=1;i<=n;i++)
// {
// for (int j=1;j<=m;j++)
// {
// if (i==1|| j==1 || i==n || j==m)
// {
// cout<<"*";
// }
// else{
// cout<<" ";
// }
// }
// cout<<endl;
// }
// cout<<endl;
cout<<"//Question: draw and solve the question of star triangle;"<<endl;
for (int i=1;i<=4;i++)
{
for (int j=1;j<=i;j++)
{
cout<<"*";
}
cout<<endl;
}
cout<<endl;
cout<<"QUestion: make the same pattren but in reverse which is given above"<<endl;
for(int i=1;i<=4;i++)
{
for (int j=1;j<=(4-i+1);j++)
{
cout<<"*";
}
cout<<endl;
}
cout<<endl;
cout<<"Make the paramid of the dtart pattren"<<endl;
int n,m;
cin>>n>>m;
for (int i=1;i<=n;i++)
{
for (int j=1;j<=n-i;j++)
{
cout<<" ";
}
for(int k=1;k<=i*2-1;k++)
{
cout<<"*";
}
cout<<endl;
}
cout<<"Question:print the number hollow pattren"<<endl;
cout<<endl;
cout<<"Print the hollogram pattren"<<endl;
int nn,mm;
cin>>nn>>mm;
for (int i=1;i<=nn;i++)
{
for (int j=1;j<=mm;j++)
{
if (i==1|| j==1 || i==nn || j==mm)
{
cout<<j;
}
else{
cout<<" ";
}
}
cout<<endl;
}
cout<<endl;
cout<<"Question:print the full rectangle with only number 1 and 2"<<endl;
cout<<endl;
for(i=1;i<=5;i++)
{
for (int j=1;j<=5;j++)
{
if( (i+j) % 2==0)
{
cout<<"1";
}
else
{
cout<<"2";
}
}
cout<<endl;
}
cout<<endl;
cout<<"Question: Print the triangle of numbers"<<endl;
cout<<endl;
for(int i=1;i<=5;i++)
{
for (int j=1;j<=i;j++)
{
cout<<j;
}
cout<<endl;
}
cout<<endl;
cout<<"Take a number from the uder and count digit of that number"<<endl;
cout<<endl;
int number;
int num=0;
cout<<"Enter the numbers to count"<<endl;
cin>>number;
int count=0;
while(number!=0)
{
num=number/10;
number=num;
count=count+1;
}
cout<<"The total number in the digit is:"<<count<<endl;
cout<<"Question take a number from the user and make the string reverse:"<<endl;
int remainder;
int numbr;
int reversed=0;
int number_;
cout<<"Enter the number"<<endl;
cin>>number_;
while(number_!=0)
{
remainder=number_%10;
reversed=reversed*10+remainder;
numbr=number_/10;
number_=numbr;
}
cout<<"The revered number is:"<<reversed<<endl;
cout<<endl;
cout<<endl;
cout<<"Print the factorial of N number:"<<endl;
int fact_number;
cout<<"Enter the Fact_number:"<<endl;
cin>>fact_number;
int fac=1;
while(fact_number>1)
{
fac=fac*fact_number;
fact_number--;
}
cout<<"The factorial agianst:"<<fact_number<<"is ="<<fac<<endl;
cout<<endl;
cout<<"Print the daimond in of character"<<endl;
cout<<endl;
char ch='A';
int n=45;
int m=45;
for(int r=0;r<n;r++) //from hald of daimond shape row 1 to mid which is is n;
{
for (int j=0;j<n-r;j++) //spaces 1 to nth row
{
cout<<" ";
}
for (int c=0;c<(2*r)-1;c++) //character in the row
{
cout<<char('A' + c);
}
cout<<endl;
}
for (int i=0;i<m;i++) //from middle to down from 1 to m
{
for(int s=0;s<i;s++) //printing spaces
{
cout<<" ";
}
for (int c=0;c<2*(m-i)-1;c++) //printing char
{
cout<<char('A'+c);
}
cout<<endl;
}
cout<<endl;
cout<<endl;
int a=10;
int b=10;
for(int i=1;i<=a;i++)
{
for(int j=1;j<=b;j++)
{
if (i==5 || j==5)
{
cout<<"*";
}
else
{
cout<<" ";
}
}
cout<<endl;
}
cout<<endl;
cout<<"take input from the user and print the rectangle:"<<endl;
cout<<endl;
int x;
int y;
cout<<"Enter Number for the row:"<<endl;
cin>>x;
cout<<"Enter the Number for the coloum:"<<endl;
cin>>y;
for(int i=1;i<=x;i++) //this's for the rows.
{
for(int j=1;j<=y;j++) //this is for the coloum.
{
cout<<"*";
}
cout<<endl;
}
}