Code:
#include <stdio.h>
#include <stdlib.h>
#include<math.h>
void enterNumbers(int *);
void sortingNumbers(int *);
int main () {
int i, j, t, o;
int x[10];
enterNumbers(x);
sortingNumbers (x);
getchar();
return 0;
}
void enterNumbers (int *x) {
int i;
for (i= 0; i<10; i++) {
printf("Input the %d number of your list: ", i);
scanf("%d", &x[i]);
getchar(); //eats the newline left behind
}
printf("The entered array is: ");
putchar('{');
for(i = 0; i < 10; i++) {
printf("%d, ", x[i]);
}
putchar('}');
}
/*
You work the sortingNumbers function out, similar to the above function.
Unless there is some reason to use a different loop increment (decrement) counter, use i, please.
*/
sortingNumbers()
{
for(j = 0; j <10; j++)
{
for(i = 0; i <9; i++)
{
if (x[i] > x[i+1]) // IF THE NUMBER ON THE LEFT IS BIGGER THAN HIS NEXT TO THE RIGHT
{ // THEN SWAP THEM
t = x[i];
x[i] = x[i+1];
x[i+1] = t;
} // END OF IF
} // END OF INNER LOOP.
} // END OF OUTER FOR LOOP
printf("Sorted it looks like\n");
for (i = 0; i <10; i++) {
printf("%8d", x[i]); //<--try that
}
}
Print out your comments in lowercase, and avoid excessive blank lines - maybe one out of 5 to 7 lines might be blank or nearly blank.