Thursday 7 May 2015

CONVERTING OF 1D ARRAY TO 2D ARRAY



#include<iostream.h>
#include<conio.h>
void func(int [],int)  ;
void main()
{clrscr();
int a[10],n;
cout<<HIMANSHU SINGH\n";
cout<<"enter size and array ";
cin>>n;
cout<<"\n";
for(int y=0;y<n;y++)
{
cin>>a[y];
}
func(a,n);
getch();

}
void func(int u[],int t)
{
int a2[20][20];
int i,j;
for(i=0;i<t;i++)
{ for(j=0;j<t;j++)
{if((i+j)>=t)
a2[i][j]=0;
else
a2[i][j]=u[j];
cout<<a2[i][j];
}
 cout<<endl;
}
}


OUTPUT-


No comments:

Post a Comment