In practice, command-line parameters are often the names of files to be processed by the program. So far, all my examples of array processing have used sequential access . That is, the elements of the array were processed one after the other in the sequence in which they occur in the array. But one of the big advantages of arrays is that they allow random access . That is, every element of the array is equally accessible at any given time.
Most people severely underestimate the probability.
Of course, the answer in a particular case depends on random factors, but we can simulate the experiment with a computer program and run the program several times to get an idea of how many people need to be checked on average. To simulate the experiment, we need to keep track of each birthday that we find. There are 365 different possible birthdays. The answer is a boolean value, true or false. Initially, all the values in the array, used , are false.