0% found this document useful (0 votes)
20 views2 pages

Java Pattern Programs

The document contains Java programs that display various numerical patterns. Each program is structured to print a specific pattern using nested loops, demonstrating different approaches to output formatting. Patterns include sequences of increasing and decreasing numbers in different arrangements.

Uploaded by

ahansamanta14
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views2 pages

Java Pattern Programs

The document contains Java programs that display various numerical patterns. Each program is structured to print a specific pattern using nested loops, demonstrating different approaches to output formatting. Patterns include sequences of increasing and decreasing numbers in different arrangements.

Uploaded by

ahansamanta14
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Java Pattern Programs

1.Write a program in Java to display the following pattern:

1
22
333
4444
55555

public class KboatPattern


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

2.Write a program in Java to display the following pattern:

5 4 3 2 1
4 3 2 1
3 2 1
2 1
1
public class KboatPattern
{
public static void main(String args[]) {
for (int i = 5; i >= 1; i--) {
for (int j = i; j >= 1; j--)
System.out.print( j + " ");
System.out.println();
}

}
}

3. Write the program in Java to display the following pattern:


1
21
321
4321
54321

public class KboatPattern


{
public static void main(String args[]) {
for (int i = 1; i <= 5; i++) {
for (int j = i; j >= 1; j--) {
System.out.print(j + " ");
}
System.out.println();
}
}
}

4. Write a program in Java to display the following pattern:


54321
5432
543
54
5

public class KboatPattern


{
public void displayPattern() {
for (int i = 1; i <= 5; i++) {
for (int j = 5; j >= i; j--) {
System.out.print(j + " ");
}
System.out.println();
}
}
}

5. Write a program in Java to display the following pattern:


3
44
555
6666
77777
public class KboatPattern
{
public static void main(String args[]) {
for (int i = 3; i <= 7; i++) {
for (int j = 3; j <= i; j++)
System.out.print(i);
System.out.println();
}
}
}

You might also like