To illustrate a practical example of using arrays, let’s develop a program that calculates the average age of a group of individuals.
// An array storing different ages
int
float
// Get the length of the array
int
// Loop through the elements of the array
for
}
// Calculate the average by dividing the sum by the length
// Print the average
System. |
In this example, we create a program that determines the lowest age among a set of ages:
|