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 / abhi
#include<iostream.h>
using namespace std;
int main()
{
int n,i=1,j;
cout<<"Enter no of rows:";
cin>>n;
for(;i<=n;i++)
{
for(int k=1;k<i-1;k++)
cout<<" ";//for spaces from right
for(j=i;j>0;j--)
cout<<j;//prints rightside nums
for(int l=2;l<=i;l++)
cout<<l;//prints leftside nums
cout<<endl;
}
return 0;
}
| Is This Answer Correct ? | 9 Yes | 13 No |
Post New Answer View All Answers
What is object in oop?
How oops is better than procedural?
Explain the concepts involved in Object Oriented programming.
Get me an image implementation program.
How long to learn object oriented programming?
Why do we need polymorphism in c#?
to find out the minimum of two integer number of two different classes using friend function
What is object in oop with example?
Write a program to implement OOPS concepts such as inheritance, polymorphism, friend function, operator overloading?
What is abstraction in oop with example?
design a c++ class for the chess board,provide a c++ class definition for such class(only class definition is required)
What is the difference between a constructor and a destructor?
What are the 4 pillars of oop?
What is encapsulation with real life example?
What is overloading and its types?