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
Is it possible to compare various strings with the help of == operator? What are the risks involved?
What is the use of static class?
Do I need to import java.lang package any time? Why?
What is the largest long allowed by java?
How can you set an applet’s height and width as a percentage?
Can we create our own wrapper class in java?
Is java a software?
What do u mean by variable?
Does garbage collection occur in permanent generation space in jvm?
Why parsing is done?
explain copyonwritearraylist and when do we use copyonwritearraylist?
Does java support multiple inheritances?
What is the history of java?
Is object a data type in java?
How can we find the actual size of an object on the heap?