Computer Applications
Write a program in Java to display the following pattern:
Exam
xam
am
m
Java
Java Nested for Loops
23 Likes
Answer
public class KboatPattern
{
public static void main(String args[]) {
String str = "Exam";
int n = str.length() - 1;
for (int i = n, x = 0; i >= 0; i--, x++) {
for (int j = n; j > i; j--)
System.out.print(" ");
for (int k = x; k <= n; k++)
System.out.print(str.charAt(k));
System.out.println();
}
}
}
Output

Answered By
15 Likes
Related Questions
Write a program in Java to input the values of x and n and print the sum of the following series:
S = 1 - x2/2! + x4/4! - x6/6! + ……. xn/n!
Write a program in Java to display the following pattern:
1 2 3 4 5
6 7 8 9
10 11 12
13 14
15State whether the following statement is True or False :
When break statement is applied, it terminates the loop.
State whether the following statement is True or False :
In a nested loop, break and continue can be used simultaneously.