Page 248 - CA_Blue( J )_Class9
P. 248

Write a program to print the following pattern (Using while loop):
                   Program 2
                                         1 2 3 4
                                         1 2 3 4
                                         1 2 3 4
                     1     class while_pattern2

                     2     {
                     3         public static void main()
                     4         {

                     5             int i,j;

                     6             i=1;
                     7             while(i<=3)

                     8             {   j=1;
                     9                 while(j<=4)

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

                    12                     j++;
                    13                 }

                    14                 System.out.println();
                    15                 i++;
                    16             }

                    17         }

                    18     }

                  You will get the following output:
































                   246    Touchpad Computer Applications-IX
   243   244   245   246   247   248   249   250   251   252   253