0% found this document useful (0 votes)
4 views1 page

Pattern Program

The document contains a Java program that prints a specific number pattern using nested loops. The pattern consists of decreasing numbers aligned to the right, with each row starting from the current row number down to 1. The program utilizes two nested loops: one for printing spaces and another for printing the numbers.

Uploaded by

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

Pattern Program

The document contains a Java program that prints a specific number pattern using nested loops. The pattern consists of decreasing numbers aligned to the right, with each row starting from the current row number down to 1. The program utilizes two nested loops: one for printing spaces and another for printing the numbers.

Uploaded by

ashu139127
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

// Java Program to Print the Pattern Using Nested Loops

/*
1
21
321
4321
54321
*/

public class NumberPattern {


public static void main(String[] args) {

int rows = 5;

for (int i = 1; i <= rows; i++) {


// Print leading spaces
for (int s = rows - i; s > 0; s--) {
[Link](" ");
}

// Print decreasing numbers


for (int num = i; num >= 1; num--) {
[Link](num);
}

[Link]();
}
}
}

You might also like