Write a program to accept a number and to print numbers in
pyramid format?
for eg:for a no. 5
1
212
32123
4321234
543212345

Answer Posted / rathod rajesh

for(int i=1;i<=5;i++)
{
for(int k=5;k>=i;k--)
{
System.out.print(" ");
}

for(int j=i;j>=1;j--)
{
System.out.print(j);
}
for(int j=2;j<=i;j++)
{
System.out.print(j);
}
System.out.println();

}

Is This Answer Correct ?    2 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

hi, this is raju,iam studying b.tech 2nd year,iam want know about group1 and group2 details, and we can studying without going to any instutions? please help me.

1549


what is difference between class template and template class?

2167


How do you achieve runtime polymorphism?

575


Can we create object of abstract class?

585


What is an interface in oop?

604






What is abstraction oop?

631


What are functions in oop?

594


What is difference between polymorphism and inheritance?

626


Why is polymorphism important in oop?

643


Write A Program to find the ambiguities in Multiple Inheritance? How are they resolved.(Virtual Functions)

3564


What is polymorphism and types?

611


Why do we use polymorphism in oops?

593


class type to basic type conversion

1847


Can main method override?

593


What is object and class in oops?

597