Computer Science, asked by aakritionairforeduca, 5 months ago

print follofollowing pattern in Java 1 12 123 1234 12345 123456​

Answers

Answered by bhoomidarak
2

Answer:

class pattern

{

public static void main()

{

for (int x=1; x<=5; x++)

{

for (int y=1; y<=x; y++)

{

System.out.print(y);//prints the number

}//end of y loop

System.out.println();//for moving the cursor to the next line

}// end of x loop

}// end of main

}//end of class

Answered by atrs7391
0

Easiest program:

package com.company;  

public class Main {

   public static void main(String[] args) {

       int s = 0;

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

           s = s*10+i;

           System.out.println(s);

       }

   }

}

Similar questions