Java Star pattern program | Print right angled triangle in java - Math Traders

Latest

Java Star pattern program | Print right angled triangle in java

Java program print right angled triangle on order n*n


 class pattern1{

public static void main(String[] args) {


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


for ( i=1; i<=6; i++ ) 


{

for ( j=1; j<=spc; j++ ) 

{

System.out.print(" ");

}


for ( j=1; j<=str; j++ ) 

{

System.out.print("*");

}

System.out.println(" ");

spc--;

str++;

}

}

}


output :


No comments:

Post a Comment