I've finished the code but now for some reason, which I have yet to figure out, there is an additional 0 being put into the output which is pushing out the smallest number in the array. Hopefully you guys can give me a bit of help here because I have been trying for so long to figure this out.

Thanks for any help you can give,Code:#include <iostream> using namespace std; int getElements(signed long int elements[]); void BubbleSort(signed long int elements[], int passes); void DispResult(signed long int elements[], int passes); int main(void) { int passes; signed long int elements[6] = {0,0,0,0,0}; cout << "Enter up to 5 integers or end-of-file (ctrl-z, enter, ctrl-z, enter)" << endl; passes = getElements(elements); BubbleSort(elements, passes); DispResult(elements, passes); return 0; } int getElements(signed long int elements[]) { int n, elem_num = 1; for (n=0; n<5; n++) { cout << "Please enter element " << (elem_num) << ":"; cin >> elements[n]; while ((elements[n] > 1000000) || (elements[n] < -1000000)) { cerr << "The integer must range from -1,000,000 to +1,000,000" << endl; cerr << "Please enter another integer: "; cin >> elements[n]; } elem_num++; } return elem_num; } void BubbleSort(signed long int elements[], int passes) { int a, b, temp_num=0; for(a = 0; a < (passes -1) ; ++a) { for(b = 1; b < passes; ++b) { if(elements[b-1] > elements[b] ) { temp_num = elements[b]; elements[b] = elements[b-1]; elements[b-1] = temp_num; } } } } void DispResult(signed long int elements[], int passes) { int c, num_element = 1; cout << "Sorted array" << endl; for(c=1; c <= (passes-1); c++) { cout << "Element " << num_element << ":" << elements[c] << endl; num_element++; } }

...Dan