Saturday, June 6, 2015

BlueJ Program On Pattern 1 ! 12 ! 123 ! 1234 !



A pattern like this to be displayed using Java program.

1
!
12
!
123
!
1234
!

class A
{
 public void showPattern()
 {
 int i,j,x=0,c;
 for(i=0;i< 7;i++)
 {
 c=1;
  if(i%2!=0)
  System.out.print("   !");
  else
  {
   x++;
  for(j=0;j< x;j++)
  System.out.print("   "+c++);
 }
  System.out.println();
  }
  }
   public static void main(String args[])throws Exception
  {
   A ob=new A();
   ob.showPattern();
   }
   }


Related PostBlueJ Programs On Pattern

No comments:

Post a Comment

Subscribe via email

Enter your email address:

Delivered by FeedBurner