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
What is polymorphism explain?
Question: Implement a base class Appointment and derived classes Onetime, Daily, Weekly, and Monthly. An appointment has a description (for example, “see the dentist”) and a date and time. Write a virtual function occurs_on(int year, int month, int day) that checks whether the appointment occurs on that date. For example, for a monthly appointment, you must check whether the day of the month matches. Then fill a vector of Appointment* with a mixture of appointments. Have the user enter a date and print out all appointments that happen on that date.
What is difference between inheritance and polymorphism?
How do you explain polymorphism?
What is new keyword in oops?
What is oops in simple words?
Why is destructor used?
what's the basic's in dot net
What is pointer in oop?
What is balance factor?
What is object in oop with example?
They started with the brief introduction followed by few basic C++ questions on polumorphism, inheritance and then virtual functions. What is polymorphims? How you will access polymorphic functions in C? How virtual function mechanism works?
Is html an oop?
Where You Can Use Interface in your Project
What does it mean when someone says I oop?