C Program For sorting of elements row wise in a matrix

#include<stdio.h>
#include<conio.h>
void main()
{
int a[10][10],t,i,j,p,q,k;
clrscr();
printf("enter order of matrix a");
scanf("%d%d",&p,&q);
printf("\n enter %d values",p*q);
for(i=0;i<p;i++)
{
for(j=0;j<q;j++)
scanf("%d",&a[i][j]);
}
printf("\n elements of matrix a are:");
for(i=0;i<p;i++)
{
printf("\n");
for(j=0;j<q;j++)
printf("%d\t",a[i][j]);
}
for(i=0;i<p;i++)
{
for(j=0;j<q;j++)
{
for(k=j+1;k<q;k++)
{
if(a[i][j]>a[i][k])
{
t=a[i][j];
a[i][j]=a[i][k];
a[i][k]=t;
}
}
}
}
printf("\n after sorting");
for(i=0;i<p;i++)
{
printf("\n"); printf("%d\t",a[i][j]);
}
getch();
} for(j=0;j<q;j++)



Bhanu Namikaze

Bhanu Namikaze is an Ethical Hacker, Web Developer, Student and Mechanical Engineer. He Enjoys writing articles, Blogging, Solving Errors and Social Networking. Feel Free to let me know any of your concerns about hacking or let me know if you need any more methods on hacking anything. Enjoy Learning

No comments:

Post a Comment