Star Pattern In Java | Pyramid Pattern In Java | Invert Pyramid Star Pattern In Java - Math Traders

Latest

Star Pattern In Java | Pyramid Pattern In Java | Invert Pyramid Star Pattern In Java

    Source Code To Print Invert Pyramid Star Pattern In Java Of Order N*N

class pattern1{
public static void main(String[] args) {

int str = 7, spc = 1, i, j;

for ( i=1; i<=7; i++ ) // loop to represent rows in the pattern.

{
for ( j=1; j<=2*str-1; j++ ) //loop to print star in the loop.
{
System.out.print("*");
}
System.out.println();
for ( j=1; j<=spc; j++ ) //loop to print space in the pattern.
{
System.out.print(" ");
}
str--;
spc++;
}
}
}

Output:
Pyramid Star Pattern In Java


No comments:

Post a Comment