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


Please Help Members By Posting Answers For Below Questions

How is class defined?

585


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?

1634


What is oops in simple words?

578


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?

1393


What is the example of polymorphism?

556






What is polymorphism give a real life example?

559


write a code for this. serial_number contained in the header of the file will be read , if this serial number is less than a previous serial number within a successfully processed file, or is the same as another serial number within a successfully processed file, or if the field contains anything other than 7 digits, then the file must error with the reason ‘Invalid SERIAL_NUMBER’.

1780


What is the difference between procedural programming and oops?

552


Can we define a class within the interface?

553


What do you mean by variable?

575


What is abstraction in oops with example?

774


what is difference between class template and template class?

2157


What is destructor give example?

603


Are polymorphisms mutations?

699


What is encapsulation c#?

600