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 ? | 1 Yes | 0 No |
Post New Answer View All Answers
Which variables are stored in stack?
Can a vector contain heterogenous objects?
What is classes in java?
How to reverse a string in java?
How do you break a loop?
What are the data types supported by java? What is autoboxing and unboxing?
Which method must be implemented by all threads?
Can a method inside a interface be declared as final?
What is the set interface in java programming?
What are the main differences between notify and notifyAll in Java?
Is java owned by oracle?
worst case complexities of Quick sort and Merge sort.
Can we use this () and super () in a method?
What is boolean used for?
What will be the default values of all the elements of an array defined as an instance variable?