Program to print 1
1 2
1 2 3
1 2 3 4 like that
Answer Posted / aditya
public class pattern
{
public static void main(int n)
{
int i,j,k;
for(i=1;i<=n;i++)
{
for(j=n;j>i;j--)
{
System.out.print(" ");
}
for(k=1;k<=i;k++)
{
System.out.print(+k+" ");
}
System.out.println();
}
}
Is This Answer Correct ? | 0 Yes | 1 No |
Post New Answer View All Answers
What are the main differences between notify and notifyAll in Java?
What is the reason behind using constructors and destructors?
What happens if a constructor is declared private?
Differentiate between a constructor and a method? Can we mark constructors final?
What is the difference between sleep and wait in java?
Why is a constant variable important?
Define locale.
What is the difference between Java Program Constructor and Java Program Method, What is the purpose of Java Program constructor Please Explain it Breafily?
I have multiple constructors defined in a class. Is it possible to call a constructor from another constructor’s body?
What do you mean by checked exceptions?
Is it possible to use string in the switch case?
Does java support multiple inheritance or not?
Why do you canvas?
Can we override tostring method in java?
What is java virtual machine? Explain