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

What are the two categories of data types in the java programming language?

512


What is listnode in java?

542


What are some alternatives to inheritance?

565


What does provide mean construction?

558


Explain different types of thread priorities ?

629






What is canonical name in java?

628


Explain the difference between call by refrence and call by value?

570


What is the function of http?

539


How many ways can an argument be passed to a subroutine and explain them?

585


Why do we use threads in java?

573


Detail discussions on JVM, memory management and garbage collector.

560


How is the marker interface used in Java?

616


What is lastindexof in java?

554


How do you stop a thread in java?

602


What is Session reduplication and how its done?

1569