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
What is the purpose of a default constructor?
Explain importance of inheritance in java?
What are the important methods of java exception class?
What is ascii code?
What is singleton math?
What are the 6 functions?
What is an empty class? What functionality does it offer in Java?
Define canvas?
How do you escape json?
How java is similar to c?
what invokes a threads run() method? : Java thread
What is the difference between variable & constant?
What is an example of declaration?
What is a instance variable?
What is array and arraylist in java?