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


Please Help Members By Posting Answers For Below Questions

Why char array is preferred over string for storing password?

575


What is pass by value?

506


What is the technique adopted to create an immutable class?

514


What is a databasemetadata?

537


Explain the importance of join() method in thread class?

634






What is a stringbuffer?

502


What is the simpletimezone class in java programming?

528


What is a instance variable?

574


How can you set an applet’s height and width as a percentage?

504


What are the default and parameterized constructors?

544


Does the order of public and static declaration matter in main method?

604


What is difference between printf and scanf?

508


What is boolean query?

524


What is a for loop in java?

586


What is thread pool in java with example?

534