$sum=0; for i in `cat b22`
do
sum=`echo "$sum + $i" | bc`
done; echo $sum;
would have worked if you had changed $sum=0 on the first line to sum=0
I assume that the variable sum was not set when you started so the first command turned into =0 when $sum expanded to an empty string.
However, it is pretty inefficient to invoke bc for each value you want to add. A much simpler way would be to use:
awk ' { for (i=1; i<= NF; i++) sum+=$i }
END {print sum}' b22
which only invokes awk once instead of invoking bc 265 times. (Note that you have 265 values in b22; not 256.)
I hate to argue with my own suggestions, but I didn't actually try looping through calls to bc when I saw the obvious typo. The rest of the shell script looked OK. What I didn't notice was that your input file has one entry that is "12K", so the bc adding the sum calculated from the previous values in the input + 12K fails and the remaining calls to bc also fail. It wasn't noticed when running the awk script because awk ignore non-numeric trailing characters with performing arithmetic operations on variables contain string values that start with decimal digit string (including an optional <period>).
So you need to fix your input to get correct results if you use any of the suggestions using bc. (And if "12K" wasn't supposed to be "12", you get the wrong result from awk as well.)