Wednesday, October 13, 2010

Lots Of Pattern Programs In BlueJ




Program in BlueJ using nested loop to print the following Pattern.

-----------1234567--------
------------23456--------
-------------345----------
--------------4-----------
-------------345----------
------------23456---------
-----------1234567---------

class BlueJx
{
 public void show()
 {
 int j,x;
  for(int i=0;i< 4;i++)
  {
  x=1;
   for(j=0;j< i;j++)
   {
   x++;
    System.out.print(" ");
   }
    for(int k=i+j;k< 7;k++)
     System.out.print(x++);
     System.out.println();
   }
  for(int i=0;i< 3;i++)
  {
  x=1;
   for(j=i;j< 2;j++)
   {
   x++;
    System.out.print(" ");
   }
    for(int k=0;k< 3+i*j;k++)
     System.out.print(x++);
     System.out.println();
   }
   }
   }


2017 ISC Computer Application Paper Suggestion: CLICK HERE

Program in BlueJ using nested loop to print the following Pattern.


------------1--------
-----------2_2-------
----------3_3_3------
---------4_4_4_4------
--------5_5_5_5_5-----
---------4_4_4_4------
----------3_3_3-------
-----------2_2--------
------------1----------


class BlueJx
{
 public void show()
 {
 int j,x=1;
  for(int i=1;i< =5;i++)
  {
     for(j=1;j< =5-i;j++)
   {
      System.out.print(" ");
   }
    for(int k=0;k< x;k++)
{
if(k%2==0)
     System.out.print(i);
else
System.out.print(" ");
}
     System.out.println();
x=x+2;
   }
 x=1;
  for(int i=4;i >=1;i--)
  {
   for(j=i;j< =4;j++)
   {
    System.out.print(" ");
   }
    for(int k=0;k< =7-x;k++)
{
if(k%2==0)
     System.out.print(i);
else
System.out.print(" ");
}
     System.out.println();
x=x+2;
   }
    }
   }

Download eBook on BlueJ 

In the above program, two separate outer loops are used. For the first outer loop, again two inner loops are used. First inner loop prints the left side spaces and the second inner loop prints the values. The outer loop continues upto the line 5  5  5  5  5  5  …
With the iteration of the outer loop the iteration of the loop printing the space is decreased and iteration of the loop printing the digits is increased.

This is just the reverse for the second loop.

 Program in BlueJ using nested loop to print the following Pattern.

  
--------------1----------
-------------333---------
------------55555--------
-----------7777777-------
----------999999999------
-----------7777777-------
------------55555--------
-------------333---------
--------------1----------


 class BlueJx
{
 public void show()
 {
 int j,x=1;
  for(int i=1;i< =5;i++)
  {
 
   for(j=1;j< =5-i;j++)
   {
 
    System.out.print(" ");
   }
    for(int k=0;k< x;k++)
{
     System.out.print(x);

}
     System.out.println();
x=x+2;
   }

x=x-4;
  for(int i=4;i >=1;i--)
  {
   for(j=i;j< =4;j++)
   {
    System.out.print(" ");
   }
    for(int k=0;k< x;k++)
{
     System.out.print(x);
}
     System.out.println();
x=x-2;
   }

   }
    }
 Program in BlueJ using nested loop to print the following Pattern.

 6
6 12
6 12 18
6 12 18 24

class BlueJx
{
 public void show(int n)
 {
 int j,x;
  for(int i=0;i< n;i++)
  {
    x=6;
   for(j=0;j< =i;j++)
   {
 
    System.out.print(" "+x);
    x=x+6;
   }
    System.out.println();
}
}
  }

Related PostBlueJ Programs On Pattern

129 comments:

  1. how to do this pattern
    15 14 13 12 11
    10 09 08 07
    06 05 04
    03 02
    01

    ReplyDelete
    Replies
    1. class a
      {
      void main()
      {
      int i,j,k=15;
      for(i=5,i>=1;i--)
      {
      for(j=1;j<=5;j++)
      {
      System.out.print(k);
      k--;
      }
      return(k);
      System.out.println();
      }
      }
      }

      Delete
    2. 10987
      654
      32
      1
      Please help sir

      Delete
    3. class Pattern
      {
      public void show ()
      {
      int x=10;
      for(int i=0;i<=3;i++)
      {
      for(int j=i;j<=3;j++)
      {
      System.out.print(x--);
      }
      System.out.println();
      }
      }
      }

      Delete
    4. I am unable to solve this programme
      Kindly pls help me out...
      Wap in java to display the following pattern:
      13579
      35791
      57813
      79135
      91357

      Delete
    5. thank you sir,
      my name is G.Noothan.

      Delete
    6. public class cnms
      {
      public static void main()
      {int x=15;
      for(int i = 1;i<=5;i++)
      {
      for(int j=5;j>=i;j--)
      {
      if(x<10)
      {
      System.out.print("0"+x+" ");
      x--;


      }
      else
      { System.out.print(x+" ");
      x--;
      }
      }

      System.out.println();
      }
      }
      }

      Delete
    7. class Pattern_1
      {
      public static void main(String args[])
      {
      int c=15;
      for(int i=5;i>=1;i--)
      {
      for(int j=1;j<=i;j++)
      {
      System.out.print(c+" ");
      c--;
      }
      System.out.println();
      }
      }
      }

      Delete
  2. please solve the pattern
    1
    3 4
    5 6 7
    7 8 9 10

    ReplyDelete
  3. class Pattern
    {
    int i,j,x=15;
    public void show()
    {
    for (i=0; i< 5;i++)
    {
    for(j=0; j< 5-i;j++)
    {
    if(x<10)
    System.out.print(" 0"+x);
    else
    System.out.print(" "+x);
    x--;
    }
    System.out.println();
    }
    }
    }

    ReplyDelete
  4. class Pattern1
    {
    int i,j,x;
    public void show()
    {
    for(i=0;i< 4;i++)
    {
    x=i*2+1;
    for(j=0; j< =i;j++)
    {
    System.out.print(" "+x);
    x++;
    }
    System.out.println();
    }
    }
    }

    ReplyDelete
  5. 1
    12
    123
    1234

    how to print this pattern?

    ReplyDelete
    Replies
    1. class abc
      {
      public static void main()
      {
      int i,j;
      for(i=1;i<=4;i++)
      {
      for(j=1;j<=i;j++)
      {
      System.out.print(j);
      }
      System.out.println();
      }
      }
      }

      Delete
  6. class P
    {
    int i,j;
    public void show()
    {
    for(i=1;i<=4;i++)
    {
    for(j=1;j<=i;j++)
    {
    System.out.print(j);
    }
    System.out.println();
    }
    }
    }

    ReplyDelete
  7. --------1
    ------1 2 1
    ----1 2 3 2 1
    --1 2 3 4 3 2 1
    1 2 3 4 5 4 3 2 1

    (-) are spaces.

    ReplyDelete
    Replies
    1. import java.io.*;
      class Pattern
      {
      int i,j,k,m;
      int x;
      void show()
      {

      for(i=0;i<5;i++)
      {
      for(j=i*2;j<8;j++)
      System.out.print(" ");
      x=1;
      for(k=0;k<=i;k++)
      System.out.print(x+++" ");
      x=x-2;
      for(m=0;m<i;m++)
      System.out.print(x--+" ");
      System.out.println();
      }
      }
      public static void main(String args[])
      {
      Pattern ob=new Pattern();
      ob.show();
      }
      }

      Delete
  8. 101010
    01010
    1010
    010
    10
    0

    How to print this pattern ?

    ReplyDelete
    Replies
    1. class Merging
      {
      void show()
      {
      int i,j,x;
      for(i=0;i<6;i++)
      {
      if(i%2==0)
      x=1;
      else
      x=0;
      for(j=i;j<6;j++)
      {
      System.out.print(x);
      if(x>0)
      x=0;
      else
      x=1;
      }
      System.out.println();
      }
      }
      }

      Delete
  9. P
    PI
    PIN
    PINK
    PINKU
    How to print this pattern?

    ReplyDelete
    Replies
    1. class Enen
      {
      int i,j,len;
      public void show(String s)
      {
      len=s.length();
      for(i=0;i<len;i++)
      {
      for(j=0;j<=i;j++)
      System.out.print(s.charAt(j));
      System.out.println();
      }
      }
      public static void main(String args[])throws Exception
      {
      Enen ob=new Enen();
      ob.show("PINKU");
      }
      }

      Delete
  10. Sir,
    Can u solve the pattern

    A
    B C
    D E F
    G H I J
    K L M N O

    ReplyDelete
    Replies
    1. class Enen
      {
      int n=65,i,j;
      public void take()
      {
      for(i=0;i<5;i++)
      {
      for(j=0;j<=i;j++)
      {
      System.out.print((char)n);
      n++;
      }
      System.out.println();
      }
      }
      public static void main(String args[])
      {
      Enen ob=new Enen();
      ob.take();
      }
      }

      Delete
  11. how to do this:
    12345
    22345
    33345
    44445
    55555

    ReplyDelete
    Replies
    1. class P
      {
      int i,j,x;
      public void show()
      {
      for(i=1;i<=5;i++)
      {
      x=i;
      for(j=1;j<=5;j++)
      {
      System.out.print(x);
      if(j>=x)
      x++;
      }
      System.out.println();
      }
      }
      public static void main(String args[])throws Exception
      {
      P ob=new P();
      ob.show();
      }
      }

      Delete
  12. sir please explain me the concept of pattern printing in such a way so that i can be able to apply it for any type of pattern by myself....

    ReplyDelete
    Replies
    1. There is no such short cut process. Go through different pattern programs, try to understand the logic and and one day you will be able to develop your own logic.

      Delete
  13. how to make an alphabet pattern

    ReplyDelete
  14. Sir can you please give the program for the following pattern-
    1
    2 4
    1 3 5
    2 4 6 8
    1 3 5 7 9 for n=5

    ReplyDelete
    Replies
    1. #include
      void main()
      {
      int i,j,x,n;
      char ch;
      printf("Enter the no of rows: ");
      scanf("%d",&n);
      for(i=0;i<n;i++)
      {
      if(i%2==0)
      x=1;
      else
      x=2;
      for(j=0;j<=i;j++)
      {
      printf("%d",x);
      x=x+2;
      }
      printf("\n");
      }
      getch();
      }

      Delete
  15. Mr. Dhananjoy, you seem to be very good in programming...Can u tell me d simple logic or how do i understand what to do when a pattern program is given..

    ReplyDelete
    Replies
    1. Go through lots of pattern programs and try to find out the logic behind those programs. This will help you to develop your own logic.

      Delete
  16. Replies
    1. class pattern
      {
      public static void main()
      {
      int i,j;
      for(i=1;i<=5;i++)
      {
      for(j=5;j>=i;j--)
      System.out.print(j);
      System.out.println();
      }
      }
      }

      Delete
  17. Can somebody help me understanding funtion oveloading in bluej and methods

    ReplyDelete
    Replies
    1. Please check with 'function overloading' in the site and you will get related posts.

      Delete
  18. How to write this program :

    1
    10
    101
    1010
    1010

    ReplyDelete
    Replies
    1. class A
      {
      void show()
      {
      int i,j,x;
      for(i=0;i<5;i++)
      {
      x=1;
      for(j=0;j<=i;j++)
      {
      System.out.print(x);
      if(x>0)
      x=x-1;
      else
      x=x+1;
      }
      System.out.println();
      }
      }
      }

      Delete
  19. Mr. Dhananjoy Sir, can you solve the following pattern....
    123454321
    1234 4321
    123 321
    12 21
    1 1

    ReplyDelete
    Replies
    1. This comment has been removed by the author.

      Delete
    2. I think this program is already posted still here are the codes:

      class pt1
      {
      int i,j,k,m,x;
      void show()
      {
      for(i=0;i< 5;i++)
      {
      x=1;
      for(j=i;j< 5;j++)
      System.out.print(x++);
      for(k=0;k< i; k++)
      System.out.print(" ");
      x=x-1;
      for(m=i;m< 5;m++)
      System.out.print(x--);
      System.out.println();
      }
      }
      public static void main(String args[])
      {
      pt1 ob=new pt1();
      ob.show();
      }
      }

      Delete
  20. hello sir....can u solve the following pattern (nested for):-

    1
    !
    12
    !
    123
    !
    1234
    !


    thank you in advance :D

    ReplyDelete
    Replies
    1. When will you post?Its been two years since you haven't posted for this pattern... # Dhananjoy Chakraborty

      Delete
  21. I want program for this pattern
    #
    ##
    ###
    ####
    #####
    ####
    ###
    ##
    #

    ReplyDelete
    Replies
    1. class Pat
      {
      void showPattern()
      {
      int i,j,x=0;
      for(i=0;i<7;i++)
      {
      if(i<=7/2)
      x++;
      else
      x--;
      for(j=0;j<x;j++)
      {
      System.out.print("#");

      }
      System.out.println();
      }
      }
      public static void main(String args[])
      {
      Pat ob=new Pat();
      ob.showPattern();
      }
      }

      Delete
  22. WRITE A PROGRAM FOR THE FOLLOWING PATTERN-
    OUTPUT:


    1 1
    2
    3 3
    4 4
    5 5
    L=5,INTERSECTIONPOINT=2

    ReplyDelete
  23. WAP TO ACCEPT THE LOWER RANGE AND UPPER RANGE FROM THE USER AND DISPLAY THE PRIME PALINDROME NUMBER IN THAT RANGE-METHODS BOOLEAN IS PRIME()
    BOOLEAN IS PALINDROME()
    VOID GENERATE()
    MAIN()

    ReplyDelete
  24. WRITE A PROGRAM FOR THE FOLLOWING PATTERN-
    OUTPUT:


    -------1----1--------
    ----------2----------
    ---------3-----3-------
    ------4----------4-----
    ---5---------------5----
    L=5,INTERSECTIONPOINT=2

    ReplyDelete
  25. 1
    12
    123
    1234
    12345
    123456

    ReplyDelete
    Replies
    1. class P
      {
      public void showPattern()
      {
      for(int i=1;i<=6;i++)
      {
      for(int j=1;j<=i;j++)
      {
      System.out.print(j);
      }
      System.out.println();
      }
      }
      }

      Delete
  26. wap to accept a word and check wether the word is palindrome or not?
    respected sir plz help

    ReplyDelete
    Replies
    1. This program already exists in my site, anyway I am again posting here.

      import java.io.*;
      class PalindromeChecking
      {
      int i,len,x;
      String str;
      BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
      public void check() throws Exception
      {
      System.out.println("Enter the Word:");
      str=br.readLine();
      len=str.length();
      x=len-1;
      for(i=0;i<len/2;i++)
      {
      if(str.charAt(i)!=str.charAt(x--))
      break;
      }
      if(i<len/2)
      System.out.println("The word is not palindrome.");
      else
      System.out.println("The word is palindrome.");
      }
      public static void main(String args[])throws Exception
      {
      PalindromeChecking ob=new PalindromeChecking();
      ob.check();
      }
      }

      Delete
  27. Wrap in java to display the area and perimeter of a circle rectangular square using the concept of function overloading .accept the length , breath,side and radius using input statement

    ReplyDelete
  28. Sir please help with wap to display
    1
    2 2
    3 3 3
    4 4 4 4
    n n n n n
    4 4 4 4
    3 3 3
    2 2
    1

    ReplyDelete
    Replies
    1. import java.io.*;
      class prg
      {
      public static void main()throws IOException
      {
      System.out.println("enter a number");
      BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
      String s=br.readLine();
      int n=Integer.parseInt(s);
      int x=1;
      for(int i=1;i<=n;i++)
      {
      for(int j=1;j<=i;j++)
      {
      System.out.print(x);
      }
      System.out.println();
      x++;
      }
      int y=n-1;
      for(int i=1;i<=n-1;i++)
      {
      for(int j=1;j<=n-i;j++)
      {
      System.out.print(y);
      }
      System.out.println();
      y--;
      }
      }
      }

      Delete
    2. import java.io.*;
      class prg
      {
      public static void main()throws IOException
      {
      System.out.println("enter a number");
      BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
      String s=br.readLine();
      int n=Integer.parseInt(s);
      int x=1;
      for(int i=1;i<=n;i++)
      {
      for(int j=1;j<=i;j++)
      {
      System.out.print(x);
      }
      System.out.println();
      x++;
      }
      int y=n-1;
      for(int i=1;i<=n-1;i++)
      {
      for(int j=1;j<=n-i;j++)
      {
      System.out.print(y);
      }
      System.out.println();
      y--;
      }
      }
      }

      Delete
  29. please help me to print this
    1
    121
    12321
    1234321
    123454321
    1234321
    12321
    121
    1

    ReplyDelete
  30. I want to print this. Please help me sir(- are spaces)
    *------------*
    --*--------*
    ----*----*
    ------ *
    ----*-----*
    --*---------*
    *-------------*

    ReplyDelete
    Replies
    1. class xprg
      {
      public static void printCross()
      {
      int size=5;
      char display='*';
      for (int row = 0; row < size; row++) {
      for (int col = 0; col < size; col++) {
      if (row == col || row + col == size - 1) {
      System.out.print(display);
      } else {
      System.out.print(" ");
      }
      }
      System.out.println();
      }
      }
      }

      Delete
  31. Please help, how to print the following pattern in bluej using nested loops
    *
    * *
    * * *
    * * * *
    * * *
    * *
    *

    ReplyDelete
    Replies
    1. class pattern
      {
      static void main()
      {
      for (int i=1;i<=4;i++)
      {
      for(int j=1;j<=i;j++)
      {
      System.out.print("*");
      }
      System.out.println();
      }
      for(int k=3;k>=1;k--)
      {
      for(int l=1;l<=k;l++)
      {
      System.out.print("*");
      }
      System.out.println();
      }
      }
      }

      Delete
  32. Please help.
    1
    2 3
    4 5 6
    7 8 9 10
    11 12 13 14 15

    ReplyDelete
    Replies
    1. class P
      {
      int i,j,x=1;
      void show()
      {
      i=1;
      for(;;)
      {
      for(j=0;j< i;j++)
      {
      System.out.print(x++);
      }
      if(x==15)
      break;
      i++;
      }
      }
      }

      Delete
    2. hOW TO MAKE THIS PATTERN IN STRING?
      J
      EE
      UUU
      LLLL
      BBBB

      Delete
    3. Please check the post on 25 October 2014

      Delete
  33. * * * * *
    * * * *
    * * *
    * *
    *
    how to print the above program..????????????

    ReplyDelete
    Replies
    1. class String1
      {
      int i,j;
      public void showPattern()throws Exception
      {
      for(i=4;i >0;i--)
      {
      for(j=i;j >0;j--)
      {
      System.out.print("*");
      }
      System.out.println();
      }
      }
      public static void main(String args[])throws Exception
      {
      String1 ob=new String1();
      ob.showPattern();
      }
      }

      Delete
    2. class pattern
      {
      public static void main(String args[])
      {
      int i,j;
      for(i=1;i<=4;i--)
      {
      for(j=1;j<=i;j++)
      System.out.print("*");
      System.out.println();
      }
      }
      }



      Delete
  34. wap to input a sentence and print the word containing maximum numbers of vowels.
    S/I: HAPPY NEW YEAR
    O/P:YEAR

    ReplyDelete
  35. 1 3 5 7 9
    3 5 7 9 1
    5 7 9 1 3
    7 9 1 3 5
    9 1 3 5 7

    ReplyDelete
  36. Write a bluej Java program to print the following

    1234*
    123*5
    12*45
    1*345
    *2345

    ReplyDelete
  37. sir please tell this pattern
    *
    **
    ***
    ****
    *****
    ******

    ReplyDelete
    Replies
    1. I am writing the loop only, complete the program yourself:


      for( int i=0;i<=6;i++)
      {
      for(int j=0;j<=i;j++)
      {
      System.out.print("*");
      }
      System.out.println();
      }
      }

      Delete
  38. sir, how to print these two patterns? Please show me their codings-

    e
    ed
    edc
    edcb
    edcba




    and





    a c e g
    i k m
    o q
    s


    ReplyDelete
  39. sir, how to print these patterns? Please show me it codings-
    *
    *#
    *#*
    *#*#
    *#*#*

    ReplyDelete
    Replies
    1. import java.io.*;
      class A
      {
      int i,j;
      public void show ()
      {
      for(i=0;i< 5;i++)
      {
      for(j=0;j<=i;j++)
      {
      if(j%2==0)
      System.out.print("*");
      else
      System.out.print("#");
      }
      System.out.println();
      }
      }
      public static void main(String args[])throws Exception
      {
      A ob=new A();
      ob.show();
      }
      }

      Delete
  40. sir, can you please send me the program for these patters
    54321 
    5432 
    543 
    54


    1
    12
    123
    1234
    12345

    * * * *
    * * *
    * * * *
    * * *
    * * * *
    * * *
    * * * *

    ReplyDelete
    Replies
    1. 54321
      5432
      543
      54
      5

      1
      12
      123
      1234
      12345

      class A
      {
      int i,j,col=5, x=5,val;
      public void take ()
      {
      for( i=0;i<11;i++)
      {
      for(j=0;j<x;j++)
      {
      System.out.print(" "+col);
      if(i<=11/2)
      col--;
      else
      col++;
      }
      System.out.println();
      if(i<11/2)
      {
      x--;
      col=5;
      }
      else
      {
      x++;
      col=1;
      }

      }
      }
      public static void main(String args[])
      {
      A object=new A();
      object.take();
      }
      }


      * * * *
      * * *
      * * * *
      * * *
      * * * *
      * * *
      * * * *




      class A
      {
      int i,j,x;
      public void take ()
      {
      for( i=0;i<7;i++)
      {
      if(i%2==0)
      x=4;
      else
      x=3;
      for(j=0;j<x;j++)
      {
      System.out.print("*");
      }
      System.out.println();
      }
      }
      public static void main(String args[])
      {
      A object=new A();
      object.take();
      }
      }

      Delete
  41. ......E
    .....TE
    ....UTE
    ...PUTE
    ..MPUTE
    .OMPUTE
    COMPUTE

    ReplyDelete
    Replies
    1. class Bill
      {
      String s="COMPUTE";
      int i,j,k,len;

      void show()
      {
      len=s.length();
      for(i=len-1;i>=0;i--)
      {
      for(j=i;j>=0;j--)
      System.out.print(" ");
      for(k=i;k<=len-1;k++)
      System.out.print(s.charAt(k));
      System.out.println();
      }
      }
      public static void main(String args[])
      {
      Bill ob=new Bill();
      ob.show();
      }
      }

      Delete
  42. Sir this one plzzz:-


    1234567
    12345
    123
    1


    ReplyDelete
    Replies
    1. class Bill
      {
      int i,j,k,x=6;

      void show()
      {
      for(i=0;i<=3;i++)
      {
      k=1;
      for(j=0;j<=x;j++)
      System.out.print(k++);
      System.out.println();
      x=x-2;
      }
      }
      public static void main(String args[])
      {
      Bill ob=new Bill();
      ob.show();
      }
      }

      Delete
  43. please solve this pattern
    1
    22
    333
    4444

    ReplyDelete
  44. please solve this pattern
    1
    2 2
    3 3 3
    4 4 4 4

    ReplyDelete
    Replies
    1. class Bill
      {
      int i,j;

      void show()
      {
      for(i=1;i<=4;i++)
      {
      for(j=1;j<=i;j++)
      System.out.print(i+ " ");
      System.out.println();
      }
      }
      public static void main(String args[])
      {
      Bill ob=new Bill();
      ob.show();
      }
      }

      Delete
  45. how print this pattern
    1a
    1a 2b
    1a 2b 3c
    1a 2b 3c 4d

    ReplyDelete
  46. B L U E J
    L U E J B
    U E J B L
    E J B L U
    J B L U E

    please tell me how to print this pattern

    ReplyDelete
  47. sir i needed guidance in fibonacci series

    ReplyDelete
  48. Replies
    1. class Pat
      {
      int i,j;
      void showPattern()
      {
      for(i=5;i>=1;i--)
      {
      for(j=i;j>=1;j--)
      {
      System.out.print(i);
      }
      System.out.println();
      }
      }
      }

      Delete
  49. 1
    1 1
    1 1 2
    1 1 2 3 (for n lines)

    Thanks in advance

    ReplyDelete
    Replies
    1. follow the site and I'll post the solution very soon.

      Delete
  50. please help me with this!!!!!

    1
    1 2
    1 2 3
    1 2 3 4
    1 2 3 4 5

    ReplyDelete
  51. sir please solve this pattern:

    ............C.....
    ...........CO.....
    ..........COM.....
    ........ COMP.....
    ........COMPU.....
    .......COMPUT.....
    ......COMPUTE.....
    .....COMPUTER.....

    ReplyDelete
    Replies
    1. class Pat
      {
      String s="COMPUTER";
      int i,j,k,len;
      public void show()
      {
      len=s.length();
      for(i=0;i<=len-1;i++)
      {
      for(j=i;j<=len-2;j++)
      System.out.print(" ");
      for(k=0;k<=i;k++)
      System.out.print(s.charAt(k));
      System.out.println();
      }
      }
      public static void main(String args[])
      {
      Pat ob=new Pat();
      ob.show();
      }
      }

      Delete
  52. Very beneficial and knowledgeable ..Thank u so much SIR CHAKROBORTY.SIR could u guide me in understanding array related programs that would be beneficial 4 me in my ICSE 10TH Exam 2017

    ReplyDelete
  53. 123454321
    1234 4321
    123 321
    12 21
    1 1

    ReplyDelete
    Replies
    1. class pt1
      {
      int i,j,k,m,x;
      void show()
      {
      for(i=0;i<5;i++)
      {
      x=1;
      for(j=i;j<5;j++)
      System.out.print(x++);
      for(k=0;k<i; k++)
      System.out.print(" ");
      x=x-1;
      for(m=i;m<5;m++)
      System.out.print(x--);
      System.out.println();
      }
      }
      public static void main(String args[])
      {
      pt1 ob=new pt1();
      ob.show();
      }
      }

      Delete
  54. Plz do this program pattern
    1
    1_2
    1_2_3
    1_2_3_4
    1_2_3_4_5
    _ stands for space

    ReplyDelete
  55. can anyone help me
    9
    9 7
    9 7 5
    9 7 5 3
    9 7 5 3 1

    ReplyDelete
    Replies
    1. class P
      {
      int i,j,x;
      public void display()
      {
      for(i=0;i<=4;i++)
      {
      x=9;
      for(j=0;j<=i;j++)
      {
      System.out.print(x);
      x=x-2;
      }
      System.out.println();
      }
      }
      }

      Delete
  56. please help with this one
    1
    3 1
    5 3 1
    7 5 3 1
    9 7 5 3 1

    ReplyDelete
  57. #
    # #
    # # #
    # # # #
    Through scanner method pls sir

    ReplyDelete
    Replies
    1. You have fixed number of rows and columns in the pattern, why do you need Scanner class for this program?

      Delete
  58. Sir please this program:
    L
    AL
    IAL
    RIAL
    TRIAL

    ReplyDelete
    Replies
    1. class P
      {
      int i,j;
      String str="TRIAL";
      int len;
      public void show()
      {
      len=str.length()-1;
      for(i=len;i>=0;i--)
      {
      for(j=i;j<=len;j++)
      {
      System.out.print(str.charAt(j));
      }
      System.out.println();
      }
      }
      public static void main(String args[])
      {
      P ob=new P();
      ob.show();
      }
      }

      Delete
  59. Plz help me withthis one
    333
    22
    1

    ReplyDelete
    Replies
    1. class A
      {
      public void show()
      {
      for(int i=3;i>=1;i--)
      {
      for(int j=i;j>=1;j--)
      {
      System.out.print(i);
      }
      System.out.println();
      }
      }
      public static void main(String args[])
      {
      A ob=new A();
      ob.show();
      }
      }

      Delete
  60. 9
    79
    579
    3579
    13579
    Please help me to write the code

    ReplyDelete
  61. I want this answer
    0
    1 1
    2 3 5
    8 13 21 34

    ReplyDelete

Subscribe via email

Enter your email address:

Delivered by FeedBurner