answersLogoWhite

0


Best Answer

#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]);

}

}

}

User Avatar

Wiki User

10y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Write a c program to sort the elements of the matrix in ascending order?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How do you write a java program to find the transpose of the matrix for the given elements?

You basically write a nested for loop (one for within another one), to copy the elements of the matrix to a new matrix.


How do you write c program to perform sum of elements of matrix using pointers with functions?

i cant write


Write a C program using dynamic memory allocation to find the sum of elements of a matrix?

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 multiply 33 matrix.?

write a program to multily 3*3 matrix.


How do you write a program that calculates the sum of the matrix elements given numbers?

ring me and ill explain - 086 22222222222222227 ring me


2x2 matrix multiplication program in 8085 processor?

how to write a program for matrix multiplication in microprocesspr


How do you Write A program in c language for checking a diagonal matrix?

Write a program in c++ that take input in a integer matrix of size 4*4 and find out if the entered matrix is diagonal or not.


A c program to square matrix?

A C program to square matrix is a math problem. In the math problem you write down all the outer boundary values of matrix in a circle, then write down the inner value.


Write a c program to find eigenvalue of a matrix?

Yes, do write. That's what you always have to do when you have got a homework-program.


How do you write a java program to find the ad joint of a matrix?

bgfygfrhjyuyhh


Write a program to print the sum of a sparse matrix?

This is a directive, not a question.


Write a C program to find sum of 3 matrices?

matrix