Tell me the programme for this
@
1 2
@ @ @
1 2 3 4
Answer Posted / chantiraji
public class TriangleDisplay {
public static void main(String[] args) {
int n = 4;
for (int i = 1; i <= n; i++) {
for (int j = 4; j < 2 * n - i; j++) {
System.out.print(" ");
}
for (int j = 1; j <= i; j++) {
if (i % 2 != 0) {
System.out.print("@" + " ");
} else {
System.out.print(j + " ");
}
}
System.out.println();
}
}
}
Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
Explain the reason behind ending a program with a system.exit(0)?
Name container classes in java programming?
What is int argc char * argv?
What is type conversion in java?
What is an accessor?
What is the significance of listiterator?
What are the 3 types of control structures?
Is it possible to compare various strings with the help of == operator? What are the risks involved?
What are facelets templates?
Why is java called java?
What is an argument in java?
is it possible to instantiate the math class?
What is a method vs function?
What is bom encoding?
Can memory leak happen java?