#=
Description:  Program creates array of 10 elements
              and assigns value to each one. It then
              computes the average of the numbers,
              and finds minimum and maximum values
Author: Tushar Gautam
Date: 8th Jan 2022
=#

# Initialising undefined (zeros) array
arr = Array{Int64}(undef, 10)

# Adding random numbers to arr
for i=1:10
    @inbounds arr[i] = rand(0:100)
end
return arr

#=
The same thing can be done in 1 line as follows:
arr = rand(0:100, 10)
=#

println("Array: ", arr)

# Computing average
avg = 0
for i=1:10
    @inbounds global avg += arr[i]
end
avg = avg / 10

# Same can be done using code: avg = sum(arr)/10

println("Average: ", avg)

# Finding minimum and maximum
minVal = arr[1]
maxVal = arr[1]
for i=2:10
    if arr[i] < minVal
        @inbounds global minVal = arr[i]
    end
    if arr[i] > maxVal
        @inbounds global maxVal = arr[i]
    end
end

#=
Same can be done using following code:
minVal = minimum(arr)
maxVal = maximum(arr)
=#

println("Minimum: ", minVal)
println("Maximum: ", maxVal)
