Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

What is object in oop?

1060


How oops is better than procedural?

1026


Explain the concepts involved in Object Oriented programming.

1144


Get me an image implementation program.

1938


How long to learn object oriented programming?

1028


Why do we need polymorphism in c#?

1095


to find out the minimum of two integer number of two different classes using friend function

2075


What is object in oop with example?

1176


Write a program to implement OOPS concepts such as inheritance, polymorphism, friend function, operator overloading?

4677


What is abstraction in oop with example?

1061


design a c++ class for the chess board,provide a c++ class definition for such class(only class definition is required)

6621


What is the difference between a constructor and a destructor?

1174


What are the 4 pillars of oop?

1089


What is encapsulation with real life example?

977


What is overloading and its types?

1078