1. ## Bubblesort malfunctioning

#include<stdio.h>

int main()
{
int /* PersonID,Wage,Sex,Age, */ n, i;
int a[10][4];
printf("please enter the amount of people you will use \n");
scanf("%d",&n);
printf("\n=%d\n\n", n);
for (i=0; i<n; i++)
{
printf("please enter the Person ID (person %d)\n", n);
scanf("%d",&a[i][0]);
printf("please enter the Wage (person %d)\n", n);
scanf("%d",&a[i][1]);
printf("please enter the Age (person %d)\n", n);
scanf("%d",&a[i][2]);
printf("please enter the Sex use 1 for male and 0 for female (person %d)\n", n);
scanf("%d",&a[i][3]);
}

printf("\t Survey Data:\n");
printf("\t~~~~~~~~~~~~~~~~~~~\n");
for (i=0; i<n; i++)
{
printf("Person %d\t", i);
printf("ID: %d\t", a[i][0]);
printf("Wage: %d\t", a[i][1]);
printf("Sex: %d\t", a[i][2]);
printf("Age: %d\t\n", a[i][3]);
}

int t;
char sort;
t=1;
while (t==1)
{
printf("\n\rHow do you want the data to be sorted ?");
printf("\n\rAscending by Person ID,type a");
printf("\n\rAscending by Wage, type b");
printf("\n\rAscending by Age, type c");
printf("\n\rOnly females, print d");
printf("\n\rOnly males, print e\n\r");
scanf("\n%c",&sort);
if (sort='a')/* Sort for ID*/
{
{
int i, j, temp;
for( j = 0; j < n - 1; j++ )
for( i = 0; i < n - j + 1; j++ )
if( a[i][0] > a[i + 1][0] )

{
temp = a[i][0];
a[i][0] = a[i + 1][0];
a[i + 1][0] = temp;
}
}

}
for (i=0; i<n; i++)
{
printf("Person %d\t", i);
printf("ID: %d\t", a[i][0]);
printf("Wage: %d\t", a[i][1]);
printf("Sex: %d\t", a[i][2]);
printf("Age: %d\t\n", a[i][3]);
}
printf("Would you like to sort the data again Yes = 1 No = 0 \n");
scanf("%d",&t);
}return 0;
}

The sort is only operationional under option a haven't implemented the others yet........... basically the sort only passes the first 2 numbers entered into the array can someone have a look at this for me thanks !

2. Do a board search for bubble sort

> int t;
> char sort;
This inline declaration smacks of C++ - where is your function called sort?

> if (sort='a')/* Sort for ID*/
And this should be
if (sort=='a')/* Sort for ID*/