KEMBAR78
SDC Looping Excercise | PDF | Computer Programming | Software Engineering
0% found this document useful (0 votes)
45 views17 pages

SDC Looping Excercise

The document contains a series of star patterns and numerical patterns, organized into various sections labeled as Pattern-I through Pattern-XXX. Each pattern showcases different arrangements of stars or numbers, including right triangles, pyramids, inverted shapes, and more. The patterns serve as exercises for practicing loops and nested structures in programming.

Uploaded by

sgrmaru17
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views17 pages

SDC Looping Excercise

The document contains a series of star patterns and numerical patterns, organized into various sections labeled as Pattern-I through Pattern-XXX. Each pattern showcases different arrangements of stars or numbers, including right triangles, pyramids, inverted shapes, and more. The patterns serve as exercises for practicing loops and nested structures in programming.

Uploaded by

sgrmaru17
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

Looping Exercise

Pattern-I Pattern-II Pattern-III

* * *
** * * **
*** * * * ***
**** * * * * ****
***** * * * * * *****

Pattern-IV Pattern-V Pattern-VI

* * * * * ***** *****
* * * * **** ****
* * * *** ***
* * ** **
* * *

Pattern-VII Pattern-VIII Pattern-IX

***** ***** *****


***** ***** *****
***** ***** *****
***** ***** *****
***** ***** *****

Pattern-X Pattern-XI Pattern-XII

* * * * * * *
* * * * * * * * * * * * * * *
* * * * * * * * * * * * * *
* *
* * * * * * * * * *
* * * *
* * * * * * * * * * * * * * *
* * * * * * *
Looping Exercise
Pattern-XIII Pattern-XIV Pattern-XV

* * * * * * *
** * * * * **
*** * * * ***
**** * * ****
***** * *****
**** * * ****
*** * * * ***
** * * * * **
* * * * * * *

Pattern- XV Pattern- XVII Pattern- XVIII

***** * *****
**** *** ****
*** ***** ***
** ******* **
* ********* *
** ******* **
*** ***** ***
**** *** ****
***** * *****

Pattern-XIX Pattern-XX Pattern-XXI

* **** * ***
* *
* * * **
* * * * * * *
* * * * * * *
* * * * * * * * * * *
* * * * * * *
* * * * *
* *
* * * **
* *
* **** * ***
Looping Exercise
Pattern-XXII Pattern--XXIII Pattern--XXIV

* *
*
** **
* *
* * * * * *
* * * * * *
* * * * * *
* *
* * * *
* * * * * * *
******* *******

Pattern-XXV Pattern-XXVI Pattern- XXVII

******* * * * * * * * *******
* * * * * *
* * * * * *
* * * * * *
* * * * * *
** * * **
* * *

Pattern- XXVIII Pattern-XXIX Pattern-XXX

***** ***** *****


* * ** * *
* * ** * *
* * ** * *
***** ***** *****
Right Triangle Star Pattern-I

1 1 5 1
12 22 54 21
123 333 543 321
1234 44444 5432 4321
12345 555555 54321 54321
1 1 1 A
2 3 01 10 B C
4 5 6 101 101 D E F
7 8 9 10 0101 1010 G H I J
1112131415 10101 10101 K L M N O
A A 1 5
AB A E 10 45
ABC A E I 100 345
ABCD A E IO 1000 2345
ABCDE A E IO U 10000 12345

Pyramid Star Pattern -II

1 1 5 1
12 22 54 21
123 333 543 321
1234 44444 5432 4321
12345 555555 54321 54321
1 1 1 A
2 3 01 10 BC
4 5 6 101 101 DEF
7 8 9 10 0101 1010 GHIJ
1112131415 10101 10101 KLMNO
A A 1 5
BB A E 10 45
CCC A E I 100 345
DDDD A E IO 1000 2345
EEEEE A E IO U 10000 12345
1 5 A
121 545 ABA
12321 54345 ABCBA
1234321 5432345 ABCDCBA
123454321 543212345 ABCDEDCBA
Left Triangle Star Pattern-III
1 1 5 1
21 22 45 12
321 333 345 123
4321 44444 2345 1234
54321 555555 12345 12345
1 1 1 A
23 01 10 BC
456 101 101 DEF
78910 0101 1010 GHIJ
1112131415 10101 10101 KLMNO
A A 1 5
BA E A 01 54
CBA I E A 001 543
DCBA O I EA 0001 5432
EDCBA U O I E A 00001 54321

Inverted Right Triangle Star Pattern- IV


12345 55555 54321 54321
1234 4444 5432 4321
123 333 543 321
12 44 54 21
1 5 5 1
1 2 3 4 5 10101 10101 ABCDE
6 7 8 9 0101 1010 FGHI
101112 101 101 JKL
1314 01 10 MN
15 1 1 O
AAAAA A E IO U 10000 12345
BBBB A E I O 1000 2345
CCC A E I 100 345
DD A E 10 45
E A 1 5
Inverted Pyramid Star Pattern- V

12345 55555 54321 54321


1234 4444 5432 4321
123 333 543 321
12 44 54 21
1 5 5 1
1 2 3 4 5 10101 10101 ABCDE
6 7 8 9 0101 1010 FGHI
101112 101 101 JKL
1314 01 10 MN
15 1 1 O
AAAAA A E IO U 10000 12345
BBBB A E I O 1000 2345
CCC A E I 100 345
DD A E 10 45
E A 1 5
123454321 543212345 ABCDEDCBA
1234321 5432345 ABCDCBA
12321 54345 ABCBA
121 545 ABA
1 5 A

Inverted Left Triangle Star Pattern- VI


12345 55555 54321 54321
1234 4444 5432 4321
123 333 543 321
12 44 54 21
1 5 5 1
1 2 3 4 5 10101 10101 ABCDE
6 7 8 9 0101 1010 FGHI
101112 101 101 JKL
1314 01 10 MN
15 1 1 O
AAAAA A E IO U 10000 12345
BBBB A E I O 1000 2345
CCC A E I 100 345
DD A E 10 45
E A 1 5
Square Star Pattern-VII

10000 11111 1 2 3 4 5 ABCDE


11000 11122 2 4 6 8 10 BCDEF
11100 11333 3 6 9 12 15 C D E FG
11110 14444 4 8 12 16 20 D E FG H
11111 55555 5 10 15 20 25 E FG H I

Rhombus Square Star Pattern-VII

10000 11111 1 2 3 4 5 ABCDE


11000 12222 2 4 6 8 10 BCDEF
11100 12333 3 6 9 12 15 C D E FG
11110 12344 4 8 12 16 20 D E FG H
11111 12345 5 10 15 20 25 E FG H I

Rhombus Square Star Pattern-VII

1 2 3 4 5
11111 11111 ABCDE
11110 11122 2 4 6 8 10 BCDEF
11100 11333 3 6 9 12 15 C D E FG
11000 14444 4 8 12 16 20 D E FG H
10000 55555 5 10 15 20 25
E FG H I
Up Arrow Star Pattern- VIII

123454321 543212345 A B CDEDCB A EDCB A B CDE


1234 4321 5432 2345 A B CD DCB A EDCB B CDE
123 321 543 345 ABC CBA EDC CDE
12 21 54 45 AB BA ED DE
1 1 5 5 A A E E

Down Arrow Star Pattern- IX

1 1 5 5 A A E E
12 21 54 45 AB BA ED DE
123 321 543 345 AB C CBA E DC CD E
1234 4321 5432 2345 A B CD DC B A E DC B B CD E
123454321 543212345 A B CD E DC B A E DC B A B CD E

Empty Diamond Star Pattern- X

123454321 543212345 A B CDE DC BA E DC B A B CD E


1234 4321 5432 2345 A B CD DC BA E DC B B CD E
123 321 543 345 ABC CBA E DC CD E
12 21 54 45 AB BA ED DE
1 1 5 5 A A E E
12 21 54 45 AB BA ED DE
123 321 543 345 ABC CBA E DC CD E
1234 4321 5432 2345 A B CD DC BA E DC B B CD E
123454321 543212345 A B CDE DC BA E DC B A B CD E
Right Pascal's Triangle Star Pattern-XI

1 5 A A
22 54 AB B C
333 543 ABC D E F
44444 5432 ABCD G H I J
555555 54321 ABCDE K L M N O
44444 5432 ABCD P Q R S
333 543 ABC T U V
22 54 AB W X
1 5 A Y

Sandglass Star Pattern- VIII

123454321 543212345 543212345 ABCDEDCBA


1234321 4321234 5432345 ABCDCBA
12321 32123 54345 ABCBA
121 212 545 ABA
1 1 5 A
121 212 545 ABA
12321 32123 54345 ABCBA
1234321 4321234 5432345 ABCDCBA
123454321 543212345 543212345 ABCDEDCBA

LeftPascal's Triangle Star Pattern-XII

1 5 A A
22 45 BA B C
333 345 CBA D E F
44444 2345 DCBA G H I J
555555 12345 EDCBA K L M N O
44444 2345 DCBA P Q R S
333 345 CBA T U V
22 45 BA W X
1 5 A Y
Right Arrow Star Pattern-XI

12345 54321 A B CD E EDCB A


1234 5432 A B CD EDCB
123 543 ABC EDC
12 54 AB ED
1 5 A E
12 54 AB ED
123 543 ABC EDC
1234 5432 A B CD EDCB
12345 54321 A B CD E EDCB A

Diamond Star Pattern- XII

1 1 5 A
22 212 545 B C
333 32123 54345 D E F
44444 4321234 5432345 G H I J
555555 543212345 543212345 K L M N O
44444 4321234 5432345 P Q R S
333 32123 54345 T U V
22 212 545 W X
1 1 5 Y

Left Arrow Star Pattern- VIII

54321 12345 ED C B A A B CD E
4321 2345 D CBA B CD E
321 345 CBA CD E
21 45 BA DE
1 5 A E
21 45 BA DE
321 345 CBA CD E
4321 2345 D CBA B CD E
54321 12345 ED C B A A B CD E

X Star Pattern- XIX


1 1 1 7
2 2 2 6
3 3 3 5
4 4
5 5 3 5
5 6 2 6
7 7 1 7

Pattern- XXI

1 2 3 4 5 6 7 8 9 1 1 1 1 1 1 1 1 1
2 2 8 8 1 0 0 1
3 3 7 7 1 0 0 1
4 4 6 6 1 0 0 1
5 5 5 1 0 1
6 6 4 4 1 0 0 1
7 7 3 3 1 0 0 1
8 8 2 2 1 0 0 1
9 8 7 6 5 4 3 2 1 1 1 1 1 1 1 1 1 1
Hollow Right
PlusTriangle Star PatternsXXVIII
Star Pattern- XX

1 1 1
1 1
22 2 18 2
12 0
3 3 3 17 3
1 3 1
4 4 1 42 3 4
163 2 1
1 1 40 1 0 1 0 1
5 5
1 5 3 15
1 5 6 6
6 2 14
1 6 0 7777777
1 2 3 4 5 6 71 7 8 9 1
10 11 12 13

Hollow Square Star PatternsXXVIII

1234 5 11114 10101 1111 1


2 4 2 4 0 0 2 2
3 3 2 4 1 1 3 3
4 4 2 4 0 0 4 4
5432 1 23333 10101 5555 5

Pattern- XXI

1
1
0 0 2 2

1 1 4 4
0 0 8 8
1 1 16 16
0 0 32 32
1 0 1 0 1 0 1
64 32 16 8 16 32 64
Pascal Triangle
Fibonacci Triangle
1
1
11 11
21 12 21
31 23 23 31
51 34 34 4651
8 5 6 6 5 8
1 5 10 10 5 1
13 8 10 9 10 8 13
1 6 15 20 15 6 1
/* A Program to print Half Pyramid of Numbers in different languages */

1
12
123
1234
12345

C
#include<stdio.h>
#include<conio.h>
void main()
{
inti,j;
clrscr();
for(i=1;i<=5;i++) // Outer for loop
{
for(j=1;j<=i;j++ ) // Innter for loop
{
printf("%d ",j);
}
printf("\n"); // Print new line
}
getch();
}

C++
#include<iostream.h>
#include<conio.h>
void main()
{
inti,j;
clrscr();
for(i=1;i<=5;i++) // Outer for loop
{
for(j=1;j<=i;j++) // Innter for loop
{
cout<<i<<" ";
}
cout<<"\n"; // Print new line
}
getch();
}

JAVA
class Patten1
{
public static void main(String args[])
{
inti,j;
for(i=1;i<=5;i++) // Outer for loop
{
for(j=1;j<=i;j++) // Inner for loop
{
System.out.print("*");
}
System.out.println(); // Print new line
}
}
}

C#
using System;
namespaceConsoleApplication
{
class Pattern1
{
static void Main(string[] args)
{
int i, j;
for (i = 1; i <= 5; i++) // Outer for loop
{
for (j = 1; j <= i; j++) // Inner for loop
{
Console.Write(j);
}
Console.WriteLine(); // Print new line
}
Console.Read();
}
}
}
JAVA SCRIPT
<script>
vari,j;
for(i=1;i<=5;i++) // Outer for loop
{
for(j=1;j<=i;j++) // Inner for loop
{
document.write(j);
}
document.write("<br>"); // Print new line
}
</script>

PHP
<?php
for($i=1;$i<=5;$i++) // Outer for loop
{
for($j=1;$j<=$i;$j++ // Inner for loop
{
echo "$j ";
}
echo "<br>"; // Print new line
}
?>

PYTHON
for i in range(6): # Outer for loop
for j in range(i): # Inner for loop
print("*",end='')
print("") # print the new line
SHELL SCRIPT

clear
for i in {1..5} ### Outer for loop ###
do
for (( j=1; j<=$i; j++)) ### Inner for loop ###
do
echo -n "$j ";
done
echo ### print the new line ###
done

PL/SQL
declare
-- declare variables
n number:=5;
i number;
j number;
begin
-- outer for loop
for i in 1..n
loop
-- inner for loop
for j in 1..i
loop
dbms_output.put('*');
end loop;
-- print new line
dbms_output.new_line;
end loop;
end;

You might also like