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
Why do we use oops?
What is polymorphism and its types?
Why do while loop is used?
Which method cannot be overridden?
What is abstraction with example?
What is inheritance in simple words?
What is overriding in oops?
When not to use object oriented programming?
Why multiple inheritance is not allowed?
What does I oop mean?
What is overloading in oops?
What is encapsulation oop?
What is the example of polymorphism?
What is polymorphism in oops with example?
Give an example where we have to specifically use C programming language and C++ programming language cannot be used?