Monday, 9 December 2013

Unknown

Write a program to Display Invert Triangle using while loop.


/*Example
:
Input - 5
Output :
5 5 5 5 5
4 4 4 4
3 3 3
2 2
1
27
*/
class InvertTriangle {

    public static void main(String args[]) {
        int num = Integer.parseInt(args[0]);
        while (num > 0) {
            for (int j = 1; j <= num; j++) {
                System.out.print(" " + num + " ");
            }
            System.out.print("\n");
            num--;
        }
    }
}

Unknown

About Blog No Baap -

Since 2016 BlogNoBaap has been bringing you the very best in all types of web resources. Posted daily, and delivered straight to your inbox each morning.

Subscribe to this Blog via Email :