Number Pattern in Pascal in Java Program

Pascal number of rows in java. pascal number program in a java programming language. This program will print the pascal pattern in numbers in java. pascal program is an important method and pattern in every programming language

Pascal Definition

Pascal enables programmers to design complicated structured data types and create dynamic and recursive data structures like lists, trees, and graphs. Pascal has functions such as records, enumerations, subranges, dynamically allocated variables with associated pointers, and sets.

For Loop in Java

The “for” loop in Java is an entry-controlled loop that allows a user to iteratively run a block of statement(s) for a defined number of times. The number of iterations is determined by the test condition specified within the “for” loop. The Java “for” loop is one of the simplest Java loops to grasp. 

A for loop is a control flow statement that specifies iteration and allows code to be performed several times. When the number of iterations is known before entering the loop, for loops are commonly employed. For loops are shorthand for while loops in that they increase and test a loop variable.

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

Output:

1

1 2

1 2 3

1 2 3 4

1 2 3

1 2

1