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


Please Help Members By Posting Answers For Below Questions

Explain the reason behind ending a program with a system.exit(0)?

592


Name container classes in java programming?

584


What is int argc char * argv?

559


What is type conversion in java?

567


What is an accessor?

1030






What is the significance of listiterator?

559


What are the 3 types of control structures?

518


Is it possible to compare various strings with the help of == operator? What are the risks involved?

604


What are facelets templates?

585


Why is java called java?

534


What is an argument in java?

498


is it possible to instantiate the math class?

520


What is a method vs function?

545


What is bom encoding?

543


Can memory leak happen java?

586