Computer Science, asked by akshitaadhran60, 5 months ago

Write a program to print this pattern in java?
1 2 3 4 5
2 3 4 5
3 4 5
4 5
5​

Answers

Answered by Anonymous
3

Answer:

plz follow me thanks ❣️❣️❣️❣️❣️❣️

Answered by aravkhot1008
0

. Pyramid Program

*

* *

* * *

* * * *

* * * * *

Let’s write the java code to understand this pattern better.

public class Edureka

{

public static void pyramidPattern(int n)

{

for (int i=0; i<n; i++) //outer loop for number of rows(n) { for (int j=n-i; j>1; j--) //inner loop for spaces

{

System.out.print(" "); //print space

}

for (int j=0; j<=i; j++ ) //inner loop for number of columns

{

System.out.print("* "); //print star

}

System.out.println(); //ending line after each row

}

}

public static void main(String args[]) //driver function

{

int n = 5;

pyramidPattern(n);

}

}

Similar questions