**i'm trying to sort the number in the ascending order,i have a problem in doing that....im quite new to c **
*my input is a={40,50,20,30};,b={20,30,40,50};my output will be a=20 30 40 50 ,b=40 50 20 30 *
sorting all the columns of a data by one of its column
int a[10],b[10],i,j,n;
int temp;
printf("Enter the number of elements for A");
scanf("%d",&n);
printf("Enter %d integers \n ",n);
for(i=0;i<n;i++)
scanf("%d",&a[i]);
printf("Enter the number of elements of B");
scanf("%d",&n);
printf("Enter %d integers \n ",n);
for(i=0;i<n;i++)
scanf("%d",&b[i]);
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{
if (a[i]>a[j])
{
swap(a[i],a[j]);
swap(b[i],b[j]);
}
}
}
printf("\n After sorting \n");
for(i=0;i<n;i++)
printf("%d\n",a[i]);
for(i=0;i<n;i++)
printf("%d\n",b[i]);
}
swap(int x[],int i,int j)
{
int temp;
temp=x[i];
x[i]=x[j];
x[j]=temp;
}