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 number data type in java?
What is java virtual machine and how it is considered in context of java’s platform independent feature?
Can an arraylist be empty?
What do you mean by constructor?
What’s the difference between constructors and other methods?
Can we synchronize static methods in java?
Can sleep() method causes another thread to sleep?
What is a buffer in java?
How do you sort a string in java?
Explain the protected field modifier?
Why arraylist is used in java?
What is an error in java?
Can we have two methods in a class with the same name?
What is the difference between applet and application?
What is floating data type?