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
Difference between this() and super() in java ?
What is the difference between synchronized and synchronized block?
What is super keyword explain with example?
What does int argc char * argv [] mean?
How does linkedhashmap work in java?
What is the scope or life time of instance variables?
Explain with example the concept of constant variable in java.
What is java basic concept?
How many bits is size_t?
What is difference between float and double?
Explain the difference between protected and default access.
What are the special characters?
What is the difference between reader/writer and inputstream/output stream?
What is an immutable object?
What is the similarity between dynamic binding and linking?