In any compound object (such as an array or struct), if you initialize any one value (generally the first), all other values are initialized to zero by default. You can initialize each element individually, but if you are initializing to zero, only one need be given, e.g. double sum[3] = {0.0}; (also, nothing wrong with the use of sizeof, but sizeof sum/sizeof *sum will suffice.)
– David C. RankinSep 8 '16 at 18:24