0% found this document useful (0 votes)
2 views

Pattern_Type_2

The document contains Java code for various pattern printing programs, each demonstrating different output patterns using nested loops. Each class includes a main method that executes the pattern logic, producing sequences of numbers, asterisks, or special characters. The patterns range from simple sequences to more complex arrangements, showcasing different programming techniques in Java.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Pattern_Type_2

The document contains Java code for various pattern printing programs, each demonstrating different output patterns using nested loops. Each class includes a main method that executes the pattern logic, producing sequences of numbers, asterisks, or special characters. The patterns range from simple sequences to more complex arrangements, showcasing different programming techniques in Java.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

** PATTERN PROGRAM IN JAVA **

TYPE – II (Pattern)
class Pattern2_1
{ Pattern2_1.main({ });
public static void main (String args[]) 12345
{
int i,j; 1234
for ( i=5; i>=1; i--) /** Outer loop */ 123
{ 12
for ( j=1; j<=i; j++) /** Inner loop */ 1
System.out.print (j+" ");
System.out.println( );
}
}
}
**************************************************************************
class Pattern2_2
{ Pattern2_2.main({ });
public static void main (String args[ ]) 55555
{ int i, j; 4444
for ( i=5; i>=1; i--) /** Outer loop */
333
{
22
for ( j=1; j<=i; j++) /** Inner loop */
1
System.out.print (i+" ");
System.out.println( );
}
}
}
**************************************************************************
class Pattern2_3
{ Pattern2_3.main({ });
public static void main (String args[ ]) 54321
{ int i, j;
for ( i=1; i<=5; i++) /** Outer loop */ 5432
{ 543
for ( j=5; j>=i; j--) /** Inner loop */ 54
System.out.print (j+" ");
5
System.out.println ( );
}
}
}
**************************************************************************
Prepared By: AYON GHOSH 1
class Pattern2_4
Pattern2_4.main({ });
{
public static void main (String args[ ]) 11111
{ int i,j; 2222
for ( i=1; i<=5; i++) /** Outer loop */ 333
{ 44
for ( j=5; j>=i; j--) /** Inner loop */ 5
System.out.print (i+" ");
System.out.println( );
}
}
}
**************************************************************************
class Pattern2_5
{ Pattern2_5.main({ });
public static void main (String args[ ]) 13579
{ int i,j; 1357
for ( i=9; i>=1; i-=2) /** Outer loop */
135
{
for ( j=1; j<=i; j+=2) /** Inner loop */ 13
System.out.print (j+" "); 1
System.out.println( );
}
}
}
**************************************************************************
class Pattern2_6
{ Pattern2_6.main({ });
public static void main (String args[ ])
{ 99999
int i, j; 7777
for ( i=9; i>=1; i-=2) /** Outer loop */ 555
{ 33
for ( j=1; j<=i; j+=2) /** Inner loop */
System.out.print (i+" "); 1
System.out.println( );
}
}
}
**************************************************************************

Prepared By: AYON GHOSH 2


class Pattern2_7 Pattern2_7.main({ });
{
public static void main (String args[ ]) 12345
{ 2345
int i,j; 345
for ( i=1; i<=5; i++) /** Outer loop */ 45
{
for ( j=i; j<=5; j++) /** Inner loop */ 5
System.out.print (j+" ");
System.out.println( );
}
}
}
**************************************************************************
class Pattern2_8
{ Pattern2_8.main({ });
public static void main (String args[]) 10101
{
int i, j; 1010
for ( i=5; i>=1; i--) /** Outer loop */ 101
{ 10
for ( j=1; j<=i; j++) /** Inner loop */ 1
System.out.print (j%2+" ");
System.out.println( );
}
}
}
**************************************************************************
class Pattern2_9
{
Pattern2_9.main({ });
public static void main (String args[ ])
{ 11111
int i, j; 0000
for ( i=5; i>=1; i--) /** Outer loop */ 111
{
00
for ( j=1; j<=i; j++) /** Inner loop */
System.out.print (i%2+" "); 1
System.out.println( );
}
}
}

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

Prepared By: AYON GHOSH 3


class Pattern2_10
{ Pattern2_10.main({ });
public static void main (String args[ ])
{ *****
int i, j; ****
for ( i=5; i>=1; i--) /** Outer loop */
***
{
for ( j=1; j<=i; j++) /** Inner loop */ **
System.out.print ("*" +" "); *
System.out.println( );
}
}
}
**************************************************************************
class Pattern2_11
{
public static void main (String args[ ])
Pattern2_11.main({ });
{
int i, j; *@*@*
for ( i=5; i>=1; i--) /** Outer loop */ *@*@
{ *@*
for ( j=1; j<=i; j++) /** Inner loop */
*@
{
if (j%2==0) *
System.out.print ("@" +" ");
else
System.out.print ("*" +" ");
}
System.out.println( );
}
}
}
**************************************************************************

Prepared By: AYON GHOSH 4


/**Homework 1
54321
4321
321
21
1
Homework 2
97531
9753
975
97
9
Homework 3
10101
0101
101
01
1
Homework 4
13579
3579
579
79
9
Homework 5
12345
6789
012
34
5

Prepared By: AYON GHOSH 5

You might also like