Page 259 - CA_Blue( J )_Class9
P. 259

Program 14     Write a program to display the following pattern:
                                        \****
                                        *\***
                                        **\**
                                        ***\*

                                        ****\
                   1      class star_pattern_b

                   2      {
                   3          public static void main(String args[])

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

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

                   9                      if (i==j)

                  10                      System.out.print("\\");
                  11                      else
                  12                      System.out.print("*");

                  13                  }
                  14                      System.out.println();

                  15                  }
                  16              }

                  17      }


                 You will get the following output:




























                                                                                                   Nested Loop   257
   254   255   256   257   258   259   260   261   262   263   264