Star Pattern Java | Equilateral Triangle Of Order N*N | Invert Triangle - Math Traders

Latest

Star Pattern Java | Equilateral Triangle Of Order N*N | Invert Triangle

         Equilateral Triangle Of Order N*N In Java 

class pattern1{

public static void main(String[] args) {


int str = 5, spc = 0, i, j;


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


{

for ( j=1; j<=spc; j++ ) //loop to print space in the pattern.

{

System.out.print(" ");

}

for ( j=1; j<=str; j++ ) //loop to print star in the loop.

{

System.out.print("* ");

}

System.out.println();

str--;

spc++;

}

}

}


Output:

Equilateral Triangle star pattern In Java


No comments:

Post a Comment