Java Nested
Java Nested
import java.util.Scanner;
public class main{
public static void main(String[]args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
for(int i = 1; i<=n; i++){
for(int j = 1; j<=n; j++){
if(i==1 || j==1 || j==n || i==n|| i==j || j==n-i+1)
{
System.out.print("*");
}
else
{
System.out.print(" ");
}
}
System.out.println("");
}
}
}
// 8
// ********
// ** **
// * * * *
// * ** *
// * ** *
// * * * *
// ** **
// ********
// printign right angle triangle with the help of the nested loop
public class main{
public static void main(String[]args){
for(int i = 1 ; i<=5; i++){
for(int j = 1; j<=i; j++){
System.out.print("*");
}
System.out.println();
}
}
}
// *
// **
// ***
// ****
// *****
// printign right angle triangle with the help of the nested loop
public class main{
public static void main(String[]args){
for(int i = 1 ; i<=5; i++){
for(int j = 1; j<=5; j++){
System.out.print("*");
}
System.out.println();
}
}
}
/* *****
*****
*****
*****
***** */