Computer Science, asked by Anonymous, 1 year ago

write a program to print a pattern-
1
12
123
1234
12345

(java programing)

Answers

Answered by Anonymous
12

CODE :-

class pattern

{

public static void main(String args[ ])

{

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

{

for(int j=1;j<=i;j++)

{

System.out.print(j+" ");

}

System.out.println();

}

}//end of main

}//end of class


OUTPUT :-

1

1 2

1 2 3

1 2 3 4

1 2 3 4 5


Hope it helps buddy :)

__________________________________________________________

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);

      }

  }

}

Output:

1

12

123

1234

12345

Similar questions