write a program in java for the following pattern:-
1
22
333
4444
55555
Answers
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 ☑.


/*
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();
}
}
}