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
What is stringreader?
What is java Applet?
How do you convert an int to a double in java?
What is default size of arraylist in java?
What is the difference between serializable and externalizable interfaces?
What are 5 boolean operators?
What is the simpletimezone class in java programming?
Explain about method local inner classes or local inner classes in java?
How java is similar to c?
Where are the local variables stored?
Differentiate between == and equals().
How the metacharacters are different from the ordinary characters?
What is jdbc api?
What is a ?
How is garbage collection controlled?