Page 210 - CA_Blue( J )_Class10
P. 210

9          n=sc.nextInt();
                10          for (i = 1; i <= n; i++)

                11          {   for (j = 1; j <= i; j++)
                12              {  System.out.print(k + "  ");

                13                  k++;
                14              }

                15              System.out.println();
                16          }

                17      }
                18  }

                             To print the following pattern:
                Program 11        x
                                 x x
                                x x x
                               x x x x
                              x x x x x

                 1  class pattern7
                 2  {
                 3      public static void main()

                 4      {

                 5          int i,j;
                 6          for(i=1; i<=5;i++)

                 7          {   for(j=i; j<=5;j++)
                 8              {  System.out.print("  "); }

                 9              for(j=1; j<=i; j++)
                10              {  System.out.print("x"+" "); }

                11              System.out.println();
                12          }

                13      }
                14  }

                             To print the following pattern:
                Program 12   1 1 2 3 4 5
                             1 1 2 3 4 5
                             1 1 1 3 4 5
                             1 1 1 1 4 5
                             1 1 1 1 1 5
                 1  class pattern8



                208208  Touchpad Computer Applications-X
   205   206   207   208   209   210   211   212   213   214   215