// This program sorts an array's values into // ascending order #include #include main() { const int arraySize = 10; int a[arraySize ] = {2, 6, 4, 8, 10, 12, 89, 68, 45, 37}; int hold; cout << "Data items in original order" << endl; for (int i = 0; i < arraySize; i++) cout << setw(4) << a[i]; for (int pass = 1; pass < arraySize; pass++) // passes for (i = 0; i < arraySize - 1; i++) // one pass if (a[i] > a[i + 1]) { // one comparison hold = a[i]; // one swap a[i] = a[i + 1]; a[i + 1] = hold; } cout << endl << "Data items in ascending order" << endl; for (i = 0; i < arraySize; i++) cout << setw(4) << a[i]; cout << endl; return 0; }