Computer Applications
Write a program in Java to display the following pattern:
Exam
xam
am
m
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
Related Questions
State whether the following statement is True or False :
In a nested loop, break and continue can be used simultaneously.
Write a program in Java to display the following pattern:
a
ce
gik
moqsWrite a program in Java to display the following pattern:
AAAAA
BBBB
CCC
DD
EWrite a program in Java to find the sum of the following series:
S = 1 + (3/2!) + (5/3!) + (7/4!) + ……. to n