Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
61 views6 pages

Pattern

Uploaded by

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

Pattern

Uploaded by

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

PATTERN

1. {for( int i=1;i<=5;i++)


{for(int j=1;j<=i;j++)
{System.out.print("*");}
System.out.println();}
*
**
***
****
*****
2. {for( int i=1;i<=5;i++)
{for(int j=1;j<=5;j++)
{System.out.print("*");}
System.out.println();}
*****
*****
*****
*****
*****
3. {for( int i=1;i<=6;i++)
{for(int j=1;j<=6-i;j++)
{System.out.print("*");}
System.out.println();}
*****
****
***
**
*
4. {for( int i=1;i<=5;i++)
{for(int j=1;j<=10;j++)
{System.out.print("*");}
System.out.println();}
**********
**********
**********
**********
**********
5. {for( int i=1;i<=5;i++)
{for(int j=1;j<=i;j++)
{System.out.print("P");}
System.out.println();}
P
PP
PPP
PPPP
PPPPP
PATTERN
6. {for( int i=1;i<=5;i++)
{for(int j=1;j<=5;j++)
{System.out.print("P");}
System.out.println();}
PPPPP
PPPPP
PPPPP
PPPPP
PPPPP
7. {for( int i=1;i<=5;i++)
{for(int j=1;j<=i;j++)
{if(j%2==0)
System.out.print("#");
else
System.out.print("@");
}
System.out.println();}
@
@#
@#@
@#@#
@#@#@
8. {for( int i=1;i<=6;i++)
{for(int j=1;j<=6-i;j++)
{if(j%2==0)
System.out.print("#");
else
System.out.print("@");
}
System.out.println();}
@#@#@
@#@#
@#@
@#
@
9. {for( int i=1;i<=5;i++)
{for(int j=1;j<=i;j++)
{if(j%2!=0)
System.out.print("#");
else
System.out.print("@") }
System.out.println();}
#
#@
#@#
#@#@
#@#@#
PATTERN
10. {for( int i=1;i<=10;i++)
{for(int j=1;j<=i;j++)
{if(j%3!=0)
System.out.print("#");
else
System.out.print("@");}
System.out.println();}
#
##
##@
##@#
##@##
##@##@
##@##@#
##@##@##
##@##@##@
##@##@##@#
11. {for( int i=1;i<=10;i++)
{for(int j=1;j<=i;j++)
{if(j%3==0)
System.out.print("#");
else
System.out.print("@");
}
System.out.println();}
@
@@
@@#
@@#@
@@#@@
@@#@@#
@@#@@#@
@@#@@#@@
@@#@@#@@#
@@#@@#@@#@
12.
{ for( char i='A';i<='E';i++)
{for(char j='A';j<=i;j++)
{ System.out.print((char)j); }
System.out.println();}
A
AB
ABC
ABCD
ABCDE
PATTERN

13. { char k='A';


for( char i=1;i<=5;i++)
{for(char j=1;j<=i;j++)

{ System.out.print(k);
k=(char)(k+1);}
System.out.println();}
A
BC
DEF
GHIJ
KLMNO
14. { char k='A';
for( char i=1;i<=5;i++)
{for(char j=1;j<=5;j++)

{ System.out.print(k);
k=(char)(k+1);}
System.out.println();}
ABCDE
FGHIJ
KLMNO
PQRST
UVWXY
15. {
for( int i=1;i<=5;i++)
{for(int j=1;j<=i;j++)

{ System.out.print(j); }
System.out.println();}
1
12
123
1234
12345
16. { for( int i=5;i>=1;i--)
{for(int j=1;j<=i;j++)
{ System.out.print(j); }
System.out.println();}
}
12345
1234
123
12
1
PATTERN
17. {
for( int i=5;i>=1;i--)
{for(int j=5;j>=i;j--)

{ System.out.print(j); }
System.out.println();}
5
54
543
5432
54321
18. {
for( int i=5;i>=1;i--)
{for(int j=i;j>=1;j--)

{ System.out.print(j); }
System.out.println();}

}
54321
4321
321
21
1
19. {
for( int i=1;i<=5;i++)
{for(int j=1;j<=i;j++)

{ System.out.print(i); }
System.out.println();}
1
22
333
4444
55555
20.pascals triangle
for (int i = 1; i <= 5; i++)
{
int c = 1;

for (int j = 1; j <= 5-i; j++)


System.out.print(" ");
for (int j = 1; j <= i; j++)
{
System.out.print(c + " ");
c = c * (i - j) / j;
}
PATTERN
System.out.println();
}
}
}
1
11
121
1331
14641

21. for (int i = 1; i <= 5; i++)


{
int c = 1;
for (int j = 1; j <= i; j++)
{
System.out.print(c + " ");
c = c * (i - j) / j;
}
System.out.println();
}

1
11
121
1331
14641

You might also like