40 Points !!!
Write a function which accepts an integer array and its size as argument and assign the elements into a 2D array of integers. If the 1 D array is { 1 2 3 } send output will be
1 2 3
1 2 0
1 0 0
C++ || Class 11 || Computer
Answers
{
int b[10][10],i,j;
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
if(i>=j)
b[i][j]=a[j];
else
b[i][j]=0;
}
for(i=0;i<n;i++)
{ cout<<endl;
for(j=0;j<n;j++)
cout<<b[i][j]<<" ";
}
I hope it help you
the question is relate to clangauged
void assign_lower_half(int a[10],int n)
{int b[10][10],i,j;
for(i=0;i<n;i++){
for(j=0;j<n;j++)
if(i>=j)
b[i][j]=a[j];
b[i][j]=0;}
for(i=0;i<n;i++)
{ cout<<endl;
for(j=0;j<n;j++)
cout<<b[i][j]<<" ";}
#BE BRAINlY