Page 209 - CA_Blue( J )_Class10
P. 209

14      }
                  15  }

                               To print the following pattern:
                  Program 9      1 2 3 4 5
                                   2 3 4 5
                                   3 4 5
                                    4 5
                                     5

                   1  class pattern6
                   2  {

                   3      public static void main()

                   4      {
                   5          int i,j;

                   6          for(i=1;i<=5;i++)
                   7          {   for(j=1;j<i;j++)

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

                  10              {  System.out.print(j+" "); }
                  11              System.out.println();

                  12          }
                  13      }
                  14  }


                               To input the number of lines and print the Floyd’s Triangle.
                  Program 10   Say, n = 5
                               1
                               2   3
                               4   5   6
                               7   8   9   10
                               11 12 13 14 15
                   1  import java.util.*;

                   2  class floyd
                   3  {

                   4      public static void main()
                   5      {

                   6          Scanner sc= new Scanner(System.in);
                   7          int i,n,j,k = 1;
                   8          System.out.print("Enter number of lines : ");



                                                                                                                       207
                                                                                                         Nested Loop   207
   204   205   206   207   208   209   210   211   212   213   214