Page 250 - CA_Blue( J )_Class9
P. 250

Write a program to print the following pattern:
                   Program 4
                                         1
                                         11
                                         111
                                         1111
                     1     class for_pattern4

                     2     {    public static void main()
                     3         {   int i,j;

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

                     6                 {    System.out.print("1");
                     7                 }

                     8                 System.out.println();
                     9             }

                    10         }
                    11     }


                  You will get the following output:























                   Program 5      Write a program to input the number of lines and print the following triangle using for loop.
                                         $
                                         &&
                                         $$$
                                         &&&&
                                         $$$$$
                     1     class for_pattern5

                     2     {
                     3         public static void main()

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



                   248    Touchpad Computer Applications-IX
   245   246   247   248   249   250   251   252   253   254   255