I got the two dim array to work.
but i still need someone to see how i could improve on my indentation
readability!
Code:
#include <stdio.h>
#include <stdlib.h>
void sort(int *array); // prototype function
int main(int argc, char *argv[])
{
int twodim[3][3]={ // array to be sorted.
12, 3, 4,
11, 17 ,8,
5, 99, 102
};
int x,c,z;
printf("unsorted\n");
printf("--------\n");
for(x=0;x<3;x++)
for(z=0;z<3;z++)
{
printf("%i\t",twodim[x][z]);
}
printf("\n");
printf("sorted\n");
printf("------\n");
sort(twodim); //function call
for(x=0;x<3;x++)
for(z=0;z<3;z++)
{
printf("%i\t", twodim[x][z]); //display the sorted array
}
printf("\n");
getchar();
return 0;
}
void sort(int *array) // sort function
{
int temp,a,b;
for(a=0;a<9;a++)
for(b=0;b<9;b++)
if(array[a]< array[b])
{
temp = array[a];
array[a] = array[b];
array[b] = temp;
}
}