Displaying array elements using range based for loop