C++ Code Example: smallest number in array

This program outputs the smallest number from an array. For this purpose, each array element is compared with its predecessor. If this is smaller than its predecessor, it becomes the new currently smallest number. This is repeated until all array elements have been passed through.

#include <iostream>
using namespace std;

int main () {
    int quantity, i;
    int numbers[20];

    cout << "How many numbers do you want to store in array? (1 - 20) " << endl;
    cin >> quantity;

    // Store numbers in array (user input)
    for(i = 0 ; i < quantity ; i++) {
        cout << "Please enter a number: " << endl;
        cin >> numbers[i];
    }
    
    int currentNumber = numbers[0];

    // loop over array and store smallest number in first array position
    for(int i = 1; i < quantity; i++) {
        if(currentNumber > numbers[i]) {
            currentNumber = numbers[i];
        }
    }

    cout << "Smallest number in array is: " << currentNumber << endl;
}
Output
How many numbers do you want to store in array? (1 - 20) 
5
Please enter a number: 
44
Please enter a number: 
77
Please enter a number: 
22
Please enter a number: 
99
Please enter a number: 
53
Smallest number in array is: 22