sum bash

C++
#Just use following structure for summing up varibles:
sum=$((var1 + var2))
#For float numbers use next instruction:
sum=$(bc <<< $var1'+'$var2)paste -sd+ infile | bc
# Using existing file<cmd> | paste -sd+ | bc
# Using stdin
Source

Also in C++: