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
What is the difference between a window and a frame in java programming?
What is an empty string in css?
How much is a java license?
What is static in java?
Where is core java used?
Does java trim remove newline?
What is meant by singleton class?
What is hash in java?
What happens when heap memory is full?
Does it matter in what order catch statements for filenotfoundexception and ioexception are written?
Can I extend singleton class in java?
What are the advantages of functions?
Which is faster set or list in java?
What is string in java? String is a data type?
Why multiple inheritance is not supported by java?