C Programming Absolute Beginner's Guide (3rd Edition)

(Romina) #1
nums[outer] = temp;
didSwap = 1;
}
}
if (didSwap == 0)
{
break;
}
}
// Now list the array as it currently is after sorting
puts("\nHere is the list after the sort:");
for (ctr = 0; ctr < 10; ctr++)
{
printf("%d\n", nums[ctr]);
}

return(0);
}

The output from this sorting program is as follows:


Click here to view code image


Here is the list before the sort
64
17
1
34
9
5
58
5
6
70
Here is the list after the sort
1
5
5
6
9
17
34
58
64
70

Note

Your output might be different than that shown in the preceding example because
rand() produces different results between compilers. The important thing to look for
is the set of 10 random values your program generates, which should be sorted upon
Free download pdf