ICSE Class 9 Computer Applications
Question 7 of 17
Nested for loops — Question 7
Back to all questions 7
Question Question 3(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
