Tuesday, December 4, 2012

Pattern Program Using BlueJ




The following pattern is displayed using both BlueJ and C programming language. First program is in BlueJ.

1234
2341
3412
4123

class Pat1
{
 int i,j,x;
 public void show()
 {
      for(i=0;i<4 i="i" span="span">
      {
          x=i+1;
           for(j=0;j<4 j="j" span="span">
           {
                System.out.print(x);
                x++;
                if(x>4)
                x=1;
            }
            System.out.println();
        }
    }
public static void main(String args[])
{
 Pat1 ob=new Pat1();
ob.show();
}

}


No comments:

Post a Comment

Subscribe via email

Enter your email address:

Delivered by FeedBurner