1234554321
1234 4321
123 321
12 21
1 1
12 21
123 321
1234 4321
1234554321
Answer Posted / c++ coder
#include <iostream>
using namespace std;
int main()
{
int MAX =5; /*the number to which series needs to
be created*/
int i,j,k;
/* this loop will print first half of the series*/
for (int m = MAX; m >0 ; m-- )
{
cout<<endl;
for( i =0; i<m; i++) /*loop to print start
numbers from 1 to MAX in each line*/
cout<<(i+1);
for( k = 0; k< 2*(MAX-i);k++) /*space which
needs to be printed after the incremented num*/
cout<<" ";
for( j = i ; j>0 ; j--)/* loop to print
decremented num*/
cout<<j;
}
/* this loop will print next half of the series -
duplicate line skipped*/
for ( int n = 2; n <= MAX ; n++ )
{
cout<<endl;
for ( i = 0; i<n ; i++)
cout<<(i+1);
for( k = 0; k< 2*(MAX-i);k++)
cout<<" ";
for( j = i ; j>0 ; j--)
cout<<j;
}
cout<<endl;
}
Is This Answer Correct ? | 4 Yes | 0 No |
Post New Answer View All Answers
How long to learn object oriented programming?
What is overloading in oops?
just right the logic of it 1--> If few people are electing then every time ur candidate should win 2--> arrange books in box, if box carry weight == books weight then take another box..... find the no of box required.
What does and I oop mean in text?
Which is better struts or spring?
Can you name some types of inheritance?
Why interface is used?
Why polymorphism is used in oops?
What is inheritance write a program to show use of inheritance?
What is object in oop?
What is class and example?
What are the three parts of a simple empty class?
How do you achieve runtime polymorphism?
INSTANCE FIELDS DECLARED private ARE ACCESSIBLE BY THE METHODS ONLY.CAN WE CHANGE THE private FIELD OF AN OBJECT IN A METHOD OF SOME OTHER OBJECT OF THE SAME CLASS?
Whats is abstraction in oops?