Here are few pattern printing programs. Students are advised to go through the programs and if they find any problem in understanding any program, they can put comments and I will clarify each and every statement of the programs.
Pattern number 1
_1____
___121___
__12321__
_1234321_
123454321
class Pat
{
int i,j,k,m,x=1;
public void show()
{
for(i=0;i< 5;i++)
{
x=1;
for(m=i;m< 4;m++)
System.out.print(" ");
for(j=0;j< =i;j++)
{
System.out.print(x++);
}
x=x-2;
for(j=0;j< i;j++)
{
System.out.print(x--);
}
System.out.println();
}
}
public static void main(String args[])
{
Pat ob=new Pat();
ob.show();
}
}
Pattern number 2
.____A
___AA
__AAA
_AAAA
AAAAA
_AAAA
__AAA
___AA
____A
___AA
__AAA
_AAAA
AAAAA
_AAAA
__AAA
___AA
____A
class Pat
{
int i,j,m,x=4;
public void show()
{
for(i=0;i< 9;i++)
{
for(m=0;m< x;m++)
System.out.print(" ");
for(j=0;j< =4-x;j++)
{
System.out.print("A");
}
if(i< 8/2)
x--;
else
x++;
System.out.println();
}
}
public static void main(String args[])
{
Pat ob=new Pat();
ob.show();
}
}
Pattern number 3
aaaaaaaaa
bbbbbbb
ccccc
ddd
e
aaaaaaaaa
bbbbbbb
ccccc
ddd
e
class Pat
{
int i,j,m,y=9,x=97;
public void show()
{
for(i=0;i< 5;i++)
{
for(m=0;m< i;m++)
System.out.print(" ");
for(j=0;j< y;j++)
{
System.out.print((char)x);
}
x++;
y=y-2;
System.out.println();
}
}
public static void main(String args[])
{
Pat ob=new Pat();
ob.show();
}
}
Pattern number 4
54321
4321
321
21
1
54321
4321
321
21
1
class Pat
{
int i,j,m,x;
public void show()
{
for(i=0;i< 5;i++)
{
x=5-i;
for(m=0;m< i;m++)
System.out.print(" ");
for(j=0;j< 5-i;j++)
{
System.out.print(x--);
}
System.out.println();
}
}
public static void main(String args[])
{
Pat ob=new Pat();
ob.show();
}
}
Related Post: BlueJ Programs On Pattern
@jit: Please post solutions for ISC 2009 Practical Papers
ReplyDeletePrograms of 2009 ISC practical are posted in this site with different title names. Please search the programs in my site and you will find those programs.
ReplyDeletesir please approve my programs and please solve them i can't solve them
ReplyDeletePl. check today's program.
ReplyDeletehow to have such pattern in output using for statement ... plz help,, reqd urgently.
ReplyDeleteoutput:
123
456
789
class Pt
ReplyDelete{
int i,j,x=1;
public void show()
{
for( i=0; i < 3;i++)
{
for(j=0; j < 3;j++)
{
System.out.print(x++);
}
System.out.println();
}
}
}
aaaaaaaaaa
ReplyDeleteaaaa aaaa
aaa aaa
aa aa
a a
aa aa
aaa aaa
aaaa aaaa
aaaaaaaaaa
pls solve this one.
public class Pattern
ReplyDelete{
int i,j,k,y=5;
public void show()
{
for(i=0;i< 9;i++)
{
for(j=0;j< y;j++)
System.out.print("a");
if(i!=0 && i!=8)
{
for(j=0;j< 1;j++)
System.out.print(" ");
}
for(k=0;k< y;k++)
System.out.print("a");
System.out.println();
if(i>=9/2)
y++;
else
y--;
}
}
public static void main(String args[])throws Exception
{
Pattern ob=new Pattern ();
ob.show();
}
}
Can any1 teach me please? my boards are approaching! :(
ReplyDeleteGo through my site from the first page and if any doubt, post in comments section - I will help you. This much I can do for you.
ReplyDeleteSuperb site...quite helpful
ReplyDelete