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

Answer Posted / yagnik

public static void main(String args[]) throws
UnknownHostException, ClassNotFoundException
{
int count =5;

for(int i=1,h=5; i<count;i++){

for(int k=h;k>=0;k--)
{System.out.print(" ");}
for (int j=1 ;j<=i;j++){
System.out.print
(j);System.out.print(" ");
}
h--;System.out.println();
}

}

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between compile-time polymorphism and runtime polymorphism?

566


What string is utf8?

545


Why pass by reference is not possible in java?

496


What does the append?

495


Is null a value?

563






How do you check if a number is a perfect square?

512


how can i use a nonsynchronized hashtable?

2106


What is the range of a character variable?

545


Can you run java program without main method?

543


How can we find the sum of two linked lists using stack in java?

574


Explain how to force the garbage collection in java.

535


What is the properties class?

561


How to implement a multithreaded applet?

2204


Which methods cannot be overridden in java?

539


How static variable work in java?

600