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 use inheritance?
What is advantage of inheritance?
How is polymorphism achieved?
Is html an oop?
Write a program to sort the number with different sorts in one program ??
What is a class in oop?
How long to learn object oriented programming?
What does no cap mean?
Following are the class specifications: class {int a}; class {int b}; Using friend funtion,calculate the max of two objects and display it.
What is the renewal class?
What is polymorphism in oops with example?
Can we have inheritance without polymorphism?
What is polymorphism and example?
Write a C++ program without using any loop (if, for, while etc) to print prime numbers from 1 to 100 and 100 to 1 (Do not use 200 print statements!!!)
assume the program must insert 4 elements from the key board and then do the following programs.sequential search(search one of the elements),using insertion sort(sort the element) and using selection sort(sort the element).