I having trouble completing my output function. The directions I was given were to:

create copy of the original array:

in a for-loop copy the values from the original

// note that the copy is going to be destroyed in the process of the printing

while array is not empty

assume that the first element of the array is the smallest found number

for each subsequent element in the array - compare with the smallest

if the element is smaller update the smallest found

print the smallest found number

call removeNumber() with the smallest found to be removed

My code so far:

void output(int *arrayPtr, int size){

int smallest = INT_MAX;

for (int i = 0; i<size; i++) {

if (arrayPtr[i]<smallest) {

smallest = arrayPtr[i];

}

}

}

create copy of the original array:

in a for-loop copy the values from the original

// note that the copy is going to be destroyed in the process of the printing

while array is not empty

assume that the first element of the array is the smallest found number

for each subsequent element in the array - compare with the smallest

if the element is smaller update the smallest found

print the smallest found number

call removeNumber() with the smallest found to be removed

My code so far:

void output(int *arrayPtr, int size){

int smallest = INT_MAX;

for (int i = 0; i<size; i++) {

if (arrayPtr[i]<smallest) {

smallest = arrayPtr[i];

}

}

}

Topic archived. No new replies allowed.