#include<stdio.h>
main()
{
printf("Enter Order Of The Matrix\n");
int l,m;
int i,j,k,t,x;
scanf("%d%d",&l,&m);
int a[l][m],temp[l*m];
printf("Enter The Elements Row Wise...\n");
for(i=0;i<l;i++)
{
for(j=0;j<m;j++)
{
scanf("%d",&a[i][j]);
}
}
printf("Matrix A \n ");
for(i=0;i<l;i++)
{
printf("\n");
for(j=0;j<m;j++)
{
printf("%d\t",a[i][j]);
}
}
/*----------------------------------------------------------------------*/
x=0;
for(i=0;i<l;i++)
{
for(j=0;j<m;j++)
{
temp[x]=a[i][j];
x++;
}
}
for(i=0;i<l*m;i++)
{
for(j=0;j<(l*m)-1;j++)
{
if(temp[j]>temp[j+1])
{
t=temp[j];
temp[j]=temp[j+1];
temp[j+1]=t;
}
}
}
x=0;
for(i=0;i<l;i++)
{
for(j=0;j<m;j++)
{
a[i][j]=temp[x];
x++;
}
}
printf("\nMatrix A After Sort \n ");
for(i=0;i<l;i++)
{
printf("\n");
for(j=0;j<m;j++)
{
printf("%d\t",a[i][j]);
}
}
}
Chat with our AI personalities
Did you know that memory allocation is not needed to display the matrix? However, the C program is to find the sum of all the elements.
write a program to multily 3*3 matrix.
Yes, do write. That's what you always have to do when you have got a homework-program.
#include<
Yes I can. I did it in QBasic about 15 years ago.