Program to print 1
1 2
1 2 3
1 2 3 4 like that
Answer Posted / ravi jain
public class Test
{
public static void main(String[] args)
{
int sp=5;
for(int n=1;n<=5;n++)
{
for(int s=1;s<=sp;s++)
{
System.out.print(" ");
}
for(int i=1; i<=n;i++)
{
System.out.print(i+" ");
}
System.out.println();
sp--;
}
}
}
Is This Answer Correct ? | 13 Yes | 1 No |
Post New Answer View All Answers
Why do we need data structure in java?
How do I run java on windows?
What are java packages? What is the significance of packages?
I have multiple constructors defined in a class. Is it possible to call a constructor from another constructor’s body?
Explain the meaning of java applet.
Java is pass by value or pass by reference? Explain
Explain implementation and how is it different from conversion?
What is method overloading in java ?
What is the point of polymorphism java?
How do I get a substring?
What is the use of StringTokenizer class?
What does || mean in code?
What are methods of a class?
Why does my function print none?
How can we use primitive data types as objects?