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
Why do we need oop?
What is abstraction in oop with example?
What is protected in oop?
What do you mean by abstraction?
What is multilevel inheritance explain with example?
What is the important feature of inheritance?
What is class and object with example?
Whats is abstraction in oops?
How do you achieve polymorphism?
Which is better struts or spring?
What is advantage of inheritance?
Write a c++ program to display pass and fail for three student using static member function
What is an example of genetic polymorphism?
What does oop mean in snapchat?
write knight tour problem which is present in datastructure