Pattern 4

 package nestedForLoop;


import java.util.Scanner;


public class Pattern4 {

 

public static void main(String[] agrs) {

Scanner sc = new Scanner(System.in);

int a = sc.nextInt();

for(int i = 1;i<=a ;i++) {

for(int j = 1;j<=a-i ; j++) {

System.out.print("  ");

}

for(int j = 1;j<=i ;j++) {

System.out.print("x  ");

}

System.out.println();

}

}

}

Comments

Popular posts from this blog

Type Casting

Arithmetic

Pattern 1