Wednesday, December 18, 2013

Pattern Printing Program Using BlueJ




In this program, a pattern as shown below will be printed using the nested loop program.

The pattern is:

1
!
12
!
123
!
1234
!


class Pat
{
int i,j,x=1;
public void show()
{
for(i=1;i<=8;i++)
{
if(i%2==0)
{
 System.out.println("!");
 x++;
continue;
}

for(j=1;j<=x;j++)
{
System.out.print(j);
}
System.out.println();
}
}
public static void main(String args[]) throws Exception
{
Pat ob=new Pat();
ob.show();
}

}

Please visit Online Students Forum

Related PostBlueJ Programs On Pattern

No comments:

Post a Comment

Subscribe via email

Enter your email address:

Delivered by FeedBurner