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


Please Help Members By Posting Answers For Below Questions

What are the main differences between notify and notifyAll in Java?

583


What is the reason behind using constructors and destructors?

558


What happens if a constructor is declared private?

535


Differentiate between a constructor and a method? Can we mark constructors final?

676


What is the difference between sleep and wait in java?

511






Why is a constant variable important?

501


Define locale.

588


What is the difference between Java Program Constructor and Java Program Method, What is the purpose of Java Program constructor Please Explain it Breafily?

599


I have multiple constructors defined in a class. Is it possible to call a constructor from another constructor’s body?

589


What do you mean by checked exceptions?

536


Is it possible to use string in the switch case?

555


Does java support multiple inheritance or not?

601


Why do you canvas?

611


Can we override tostring method in java?

531


What is java virtual machine? Explain

571