Page 299 - CA_Blue( J )_Class9
P. 299

11                  {
                  12                      System.out.print (j);

                  13                      j++;
                  14                  }

                  15                  System.out.println();
                  16                  i--;
                  17              }

                  18          }

                  19      }
                 You will get the following output:

                                                        VARIABLE DESCRIPTION
                            NAME              DATATYPE                           DESCRIPTION
                       i                int                   Loop Variable
                       j                int                   Loop Variable

                                 Write a program to input number of lines and print the following structure:
                  Program 21
                                 1234
                                 1234
                                 1234
                                 .
                                 nth line
                   1      import java.util.*;

                   2      class pattern3                           // class name
                   3      {
                   4          public static void main()

                   5          {
                   6              Scanner sc= new Scanner(System.in);

                   7              int i,j,n;                       //Declaration of variable
                   8              System.out.print("Enter number of lines : ");

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

                  11              do                               //Loop variable for number of lines
                  12              {

                  13                  j=1;
                  14                  do                           //Loop variable for number of columns

                  15                  {
                  16                      System.out.print (j);



                                                                                             Internal Assessment  297
   294   295   296   297   298   299   300   301   302   303   304