ICSE Class 10 Computer Applications
Question 6 of 22
Nested for loops — Question 6
Back to all questions 6
Question Question 2(v)
Write a program in Java to display the following patterns.
$ $ $ $ 5
$ $ $ 4
$ $ 3
$ 2
1
public class KboatPattern
{
public static void main(String args[]) {
char ch = '$';
for (int i = 5; i >= 1; i--) {
for (int j = i-1; j >= 1 ; j--)
System.out.print(ch + " ");
System.out.print(i);
System.out.println();
}
}
}Output
