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 type of question are asked in thoughtworks pair programming round ?
What is basic concept of oop?
Why do pointers exist?
What is byval and byref? What are differences between them?
Can we define a class within the interface?
What is constructor overloading in oop?
Please send ford technologies placement paper 2 my mail id
#include
Hi friends I have experience of 6 months in website design and maintanence. Now i am looking for other IT jobs.. to switch platform. please post any interview you know in chennai.
What is inheritance write a program to show use of inheritance?
What is the difference between static polymorphism and dynamic polymorphism?
Write a c++ program to display pass and fail for three student using static member function
What is oops and its features?
What does I oop mean?
What is the problem with multiple inheritance?