Star printing program in Java, pattern 4

Star printing program in Java, pattern 4 :




Code for this pattern :

public class test {

    public static void main(String[] args) {
        int count = 0;
        int count2 = 5;
        for(int i = 0; i<5; i++){
            for(int j = 0; j<count; j++){
                System.out.print(" ");
            }
            for(int k = 0; k<2*count2-1; k++){
                System.out.print("*");
            }
            count = count+1;
            count2 = count2-1;
            System.out.println();
        }
    }
}

Try this in C.

Related post :

How to print Stars pattern in C                                          How to print Stars pattern in Java

Previous pattern                                                                                                         Next pattern

0/Post a Comment/Comments