#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
void main()
{
int a[20][20],i,j,n,count=1;
clrscr();
cout<<"Enter Number :";
cin>>n;
//Loop for storing the values in an array.
for(i=0;i<n;i++)
{
for(j=i;j<n;j++)
{
a[j][i]=count++;
}
}
//Loop for displaying the values of an array.
for(i=0;i<n;i++)
{
for(j=0;j<=i;j++)
{
cout.setf(ios::left);
cout<<setw(4)<<a[i][j];
}
cout<<endl;
}
getch();
}
No comments:
Post a Comment