Program to print 1
1 2
1 2 3
1 2 3 4 like that

Answer Posted / yun hin

class triangle{
public static void main(String args[]){
int height = 5;

for(int i=1;i<=height;i++){
for(int j=1;j<=(height-i);j++){
System.out.print(" ");
}
for(int k=1;k<i;k++){
System.out.print(k + " ");
}
System.out.print(i);
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

Difference between method overloading and method overriding in java ?

567


Write a program to print the pattern given below

495


What is void keyword?

674


What is mysql driver class name?

552


What will happen if static modifier is removed from the signature of the main method?

524






Can we inherit a class with private constructor?

569


How infinite loop is declared?

536


What is runtime locatable code?

867


How many types of memory areas are allocated by JVM in java?

592


What happens when a thrown exception is not handled?

580


Define reflection.

575


Explain the private protected method modifier?

545


What is the use of math abs in java?

548


How can you read an integer value from the keyword when the application is runtime in java? example?

620


Describe how to implement singleton design pattern in struts.

532