1:
You ask for a integer before the while
loop and then loop 20 times asking for a number. Solve this by using a do-while
loop:
do {
cin >> next;
input[index] = next;
index++;
} while ((next > 0) && (index < size))
2: Your values in the array are uninitialized if the user enters less then 20 numbers. This is undefined behavior. You can fix this by default initializing:
int input[max_integers] = { };