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
Why char array is preferred over string for storing password?
What is pass by value?
What is the technique adopted to create an immutable class?
What is a databasemetadata?
Explain the importance of join() method in thread class?
What is a stringbuffer?
What is the simpletimezone class in java programming?
What is a instance variable?
How can you set an applet’s height and width as a percentage?
What are the default and parameterized constructors?
Does the order of public and static declaration matter in main method?
What is difference between printf and scanf?
What is boolean query?
What is a for loop in java?
What is thread pool in java with example?