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 / shravya
#include<iostream.h>
using namespace std;
int main()
{
int n,i,j;
cout<<"Enter no of rows:";
cin>>n;
for(i=1;i<=n;i++)
{
for(int k=1;k<=n-i;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 ? | 23 Yes | 15 No |
Post New Answer View All Answers
What causes polymorphism?
What is encapsulation oop?
which feature are not hold visual basic of oop?
What are objects in oop?
What does and I oop mean?
Why do pointers exist?
What is abstraction encapsulation?
What is difference between pop and oop?
Templates mean
Is html an oop?
What is destructor oops?
what's the basic's in dot net
What do you mean by abstraction?
What are the 4 main oop principles?
Why is abstraction needed?