write a program in java to print pattern :. 12345
22345
33345
44445
55555
Answers
Answered by
1
import java.util.Scanner;
public class Pattern {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter n: ");
int n = scanner.nextInt();
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
if (j <= i) {
System.out.print(i + " ");
} else {
System.out.print(j + " ");
}
}
System.out.println();
}
}
Output:
12345
22345
33345
44445
55555
Similar questions
Math,
7 hours ago
Chemistry,
7 hours ago
English,
13 hours ago
Math,
7 months ago
Social Sciences,
7 months ago