A program to display the following series:


1 2 3 4
1 2 3
1 2
1
4
4 3
4 3 2
4 3 2 1

 

#include<iostream.h>
#include<conio.h>

void main()
{
clrscr();
int i,j,n;

cout<<"Enter last number in the first row: ";
cin>>n;

for(i=n;i>=1;i--)
{
for(j=1;j<=i;j++)
cout<<j<<" ";
cout<<"\n";
}

for(i=n;i>=1;i--)
{
for(j=n;j>=i;j--)
cout<<j<<" ";
cout<<"\n";
}

getch();
}

 

< Back