Computer Science, asked by priyanshi367112, 5 months ago

Rewrite the following snippet using while loop:- class pattern { public static void main(String args[]) { int i,j; for( i=5; i>=1;i--) { System.out.println (i); } System.out.println (); } } .plz give relevant answers,it's urgent plzz . don't post irrelevant answers plzzz ​

Answers

Answered by Oreki
1

Given Snippet:

   public class Pattern {

       public static void main(String[ ] args) {

           int i;

           for (i = 5; i >= 1; i--) {

               System.out.println(i);

           }

           System.out.println( );

       }

   }  

Converted to while loop:

   public class Pattern {

       public static void main(String[ ] args) {

           int i = 5;

           while (i >= 1) {

               System.out.println(i);

               i--;

           }

           System.out.println( );

       }

   }

Similar questions