Computer Applications

Write two separate Java programs to generate the following patterns using iteration (loop) statements:

5 4 3 2 1
5 4 3 2
5 4 3
5 4
5

Java

Java Nested for Loops

ICSE 2015

32 Likes

Answer

public class KboatPattern
{
    public static void main(String args[]) {
        for (int i = 1; i <=5; i++) {
            for (int j = 5; j >= i; j--) {
                System.out.print(j + " ");
            }
            System.out.println();
        }
    }
}

Variable Description Table

Program Explanation

Output

Answered By

17 Likes


Related Questions