Program to print given star pattern , using simple trick .

pattern 11
pattern 11

Question :

pattern 11

Code :

public class Pattern {
	public static void main(String[] args) {
		for (int i = 0; i < 9; i++) {
			for (int j = 0; j < 5; j++) {
				if(i+j >=8  ||  j-i >=0 )
				{
					System.out.print("* ");
				}
				else
				{
					System.out.print(" ");
				}
			}
			System.out.println();
		}
	}
}

Leave a Reply