Tuesday 29 March 2016

Published 23:04:00 by with 0 comment

Pattern program in java

public class Triangle {

    public static void main(String[] args) {

        int i, j, t = 0;
        int k;
        for (i = 0; i <= 4; i++) {

            for (j = t; j <= 4; j++) {

                System.out.print(" ");
            }
            for (k = 0; k < i; k++) {
                System.out.print(" * ");
                t = t + 1;
            }
            System.out.println(" ");

        }
    }
}

OUTPUT:-

                 *
             *      *
         *      *     *
     *     *     *      *
      edit

0 comments:

Post a Comment