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

Answer Posted / rajesh

public class Triangle {

public static void main(String args[])
{
int i,j,k,sp=30;
for(i=1;i<=5;i++)
{
for(k=0;k<sp;k++)
{
System.out.print(" ");
}
sp=sp-1;
for(j=1;j<=i;j++)
{
System.out.print(" "+j);
}
System.out.println();
}
}

}

Is This Answer Correct ?    10 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is stringreader?

523


What is java Applet?

645


How do you convert an int to a double in java?

590


What is default size of arraylist in java?

553


What is the difference between serializable and externalizable interfaces?

565






What are 5 boolean operators?

614


What is the simpletimezone class in java programming?

534


Explain about method local inner classes or local inner classes in java?

567


How java is similar to c?

584


Where are the local variables stored?

514


Differentiate between == and equals().

589


How the metacharacters are different from the ordinary characters?

564


What is jdbc api?

531


What is a ?

747


How is garbage collection controlled?

730