Computer Applications
Write a program in Java to display the following patterns.
* * * * 5
* * * 4
* * 3
* 2
1
Java
Java Nested for Loops
3 Likes
Answer
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
Answered By
1 Like
Related Questions
Write a program in Java to display the following patterns.
A B C D E A B C D A B C A B A
Write a program in Java to display the following pattern:
1**** 22*** 333** 4444* 55555
Write a program in Java to display the following pattern:
5 4 3 2 1 4 3 2 1 3 2 1 2 1 1
Write a program in Java to display the following patterns.
# * * # # # * * * * # # # # #