how to collect values from each iteration of a loop and save them bash

C++
results=()

for time in ${seconds_list}; do
    results+=($(bc -l <<< "scale=2; ($cur_time-$time)/3600"))
done

# print the results:

printf "%s\n" "${results[@]}"VARIABLE=$(for time in ...; do ...; done)
Source

Also in C++: