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


Please Help Members By Posting Answers For Below Questions

I am unable to find or learn about print command. I have a graphical program in core java in applet but i want to give print command but i have coding for that so if anyone know about this plz mail me on avdhesh_chauhan007@yahoo.co.in

1588


What is instance example?

511


What state is a thread in when it is executing?

518


What is the difference between Error, defect,fault, failure and mistake?

650


Explain the meaning of java applet.

595






Is 0 a real number?

576


In Java list the methods that can be overridden?

564


How to sort an array in java without using sort method?

520


What is 32 bit float?

551


What is the benefit of using enum to declare a constant?

648


What is the difference between abstract classes and interfaces?

501


What is set string?

586


What is private static class in java?

503


Print Vertical traversal of a Binary Tree.

599


What is mutable object and immutable object?

622