Computer Science, asked by aditixzx, 6 months ago

write a program in java for the following pattern:-

1
22
333
4444
55555​

Answers

Answered by anindyaadhikari13
2

Answer:

This is the Java program for the question.

public class Java {

 public static void main(String[] args) {

     int i, j;

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

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

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

        System.out.println();

     }

 }

}

Algorithm:

  • START.
  • Iterate the outer loop in the range 1 to 5.
  • Iterate the inner loop in the range 1 to i where i is the row number.
  • Display the value of i.
  • Print a new line after displaying the row.
  • STOP.

Refer to the attachment for output ☑.

Attachments:
Answered by atrs7391
0

/*

Project Type: Brainly Answer

Date Created: 10-02-2021

Date Edited Last Time: ---NIL---

Question Link: https://brainly.in/question/34953206

Question: Write a program in java for the following pattern:-

1

22

333

4444

55555

Program Created By: atrs7391

Programming Language: Java

Language version (When program created or last edited): jdk-15.0.2

*/

package Brainly_Answers;

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

           }

           System.out.println();

       }

   }

}

Similar questions