Computer Science, asked by anamikarawat0, 9 months ago


Write a program in Java to display the given pattern.
12
123
1 2 3 4
1 2 3 4 5​


Answers

Answered by ADDHISH
1

Answer:

  • here just do it tilllllllllllll 5
Attachments:
Answered by ashwin456ojha
2

Answer:

public class Main

{

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

       }

}

}

Explanation:

first loop that is i is external loop and j internal loop. In the first iteration we're going to maximum value that is 5 here in  second iteration we go to 1 to 2 then 1 to 3 then 1 to 4. Like this...I hope u understand...

Similar questions