Tell me the programme for this
@
1 2
@ @ @
1 2 3 4
Answer Posted / thati.donthi
public class PrintTriangle {
public static void main(String[] args) {
int n=4;
for(int i=1;i<=n;i++) {
for(int j=0;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 ? | 7 Yes | 0 No |
Post New Answer View All Answers
Can we execute a program without main?
write a program that list all permutations of ABCDEF in which A appears before B?
If a variable is declared as private, where may the variable be accessed?
What is the main difference between java platform and other platforms?
What is lossy conversion in java?
What is e in java?
How thread scheduler schedule the task?
Why volatile is used in java?
Which sorting is best in java?
Explain heap sort?
Which is the best sorting technique in java?
How is garbage collection controlled?
What are voids?
How does hashset works in java?
What are latest features introduced with java 8?