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 is the purpose of enum?
What is object and example?
Explain virtual inheritance?
How long to learn object oriented programming?
There are two base class B1,B2 and there is one class D which is derived from both classes, Explain the flow of calling constructors and destructors when an object of derived class is instantiated.
What is encapsulation in ict?
is there any choice in opting subjects like 4 out of 7
What is purpose of inheritance?
How Do you Code Composition and Aggregation in C++ ?
What are different oops concepts?
how to get the oracle certification? send me the answer
Is data hiding and abstraction same?
write a code for this. serial_number contained in the header of the file will be read , if this serial number is less than a previous serial number within a successfully processed file, or is the same as another serial number within a successfully processed file, or if the field contains anything other than 7 digits, then the file must error with the reason ‘Invalid SERIAL_NUMBER’.
write string class as your own class in java without using any built-in function
What is overriding vs overloading?