Professional Documents
Culture Documents
Lecture - 7
Raghav Garg
Ques : Print the given pattern
input
of of
1 2 3 4 5 user -
no. rows a no. columns
I
*****
2
S stars in 'n'lines
line
m ->
no.
of stars in each
n Y
=
* *
*
->
* *
m 3
=
* * *
Solid Rectangle * * *
Ques : Print the given pattern
****
****
****
****
User input
-
n-side
of square
Solid Square
Ques : Print the given pattern
3
=
n2 n 1 =
n4 n
=
1234 12 I
123
1234 123 12
1234 123
1234
for lint : =1;i c n;i +)4
= +
I conti
Number Square
n 3
=
Output
I
·
1 2 3
· 123
· 123
i x4 B
=
j Nx
=
YX
& BYARB Y
Ques : Print the given pattern Output
·
X
n 4
=
i 4 & B Y
=
*
7 · XX
j xRXRBAx B Y
**
=
2 X
***
· X X
3
**** n 3
=
⑧
Star Triangle
Ques : Print the given pattern
n =
Y
stars n+1
Row of
=
mo. t no.
****
-
i
**
* ↓ 2 3 Y
↑
I *
*
* * 4
2 *
*
* 3
i 3
4
*
*
*
2
I
for (intj= 1;j i;; 7
12
<= +
+
2
I coutj;
3 1 2 3
4 1 2 3 4
3
contende;
Number Triangle
Ques : Print the given pattern
A
nY
=
I 2 3 Y
I
1
2
13
3
135
Y 1357
L
656666 68
ABCD
1234
ABCD - 1 2 3 Y
I 234
#int:ASCII values
Alphabet Square
Ques : Print the given pattern (n 0ddS
=
1 2 3 4 S
-##
5
*
2##
*
*****
123 n 1
=
*
1 A* #
## #
#
3
*
*
2 x * Y
#
###
3 #* #
n 3
=
int mid= 1
1 +
Star Plus
Ques : Print the given pattern
I 2345
12345
* *
I 1 y
* *
2 X
2
-
*
- - -
3 x
↳
- -
* *
- - -
X
-
y
*j *
- -
- - -
S - - -
S ---
X
i +
n
=
+
1
nS
=
Star Cross
*Ques : Print the given pattern
n Y
=
456
7 8 9 10
Floyd’s Triangle
*Ques : Print the given pattern
#I:Using entra variable
I
1
2
01 if (1%2! 1
101
=
0) + se start
3
u 0 1 0 1
else -0 se start
n 4
=
alternatively
Binary Triangle
*Ques : Print the given pattern
I
2345j
I
1 if (i j) 1
01
=
= -
3
101 if it; both odd -> 1
Y
0101 is; both even - 1
10 10 1
5
if (itj %2 0) -1
=
=
-
Binary Triangle
*Ques : Print the given pattern
123 Y
Pop
L
2 ##
** loop
3 #
***
Y
**** #
#
# X
#
#
X A
I
# T X X
& &x *
n 4
=
***
- -
3 -
Y
****
i
I
=
n -i 0
=
8 X
i x23
= - -
j xRBX2
=
8 -
**
* de
k b7
=
1 ·
! -
Ques : Print the given pattern
~
1- -
I
12
--
-
I
12
123
- -
I
-
-
-
123
1234
-
1234
Assignment
-
sharp
A 44 A i1 n
2 Trangle
to
=
i 1toni
=
in iontri
R 1 to i
=
Maths
3)
Thank
You.