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
Which language is not a true object oriented programming language?
What is protected in oop?
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 are the benefits of interface?
Write a program to compute for numeric grades for a course. The course records are in a file that will serve as the input file. The input file is in exactly the following format: Each line contains a student's first name, then one space, then ten quiz scores all on one line. The quiz scores are in whole number and are separated by one space. Your program will take it input from this file and sends it output to a second file. The data in the output file will be exactly the same as the data in the input file except that there will be one additional number (of type double) at the end of each line. This number will be the average of the student's ten quiz scores. Use at least one function that has file streams as all or some of its arguments.
Why can't we have instance(stack) of a class as a member of the same class like eg.Class A{A obj;} as we can have self refential pointer
can inline function declare in private part of class?
What is data binding in oops?
i got a backdoor offer in process global,Bangalore..Can i work with it?
What is the advantage of oop over procedural language?
Is this job good for future? can do this job post grduate student?
What do you mean by Encapsulation?
Is html an oop?
What are the 4 main oop principles?
What is a null tree?