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
Why runnable interface is used in java?
Explain runtime exceptions?
Why string is immutable with example?
Can a method be overloaded based on different return type but same argument type?
Can we have more than one package statement in the source file?
What is jrmp?
What is boolean in java?
What state does a thread enter when it terminates its processing in java programming?
What is the difference between declaration and definition in java?
What is oop principle in java?
what are the high-level thread states? : Java thread
What is illegal identifier in java?
What exactly is java?
Can a class with private constructor be extended?
Define inheritance?