Computer Applications
Write a program in Java to display the following pattern:
Exam
xam
am
m
Java
Java Nested for Loops
19 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
13 Likes