If $\displaystyle M=\bigsqcup_i M_i$ is the union of connected components

$$ \begin{array}{rclcrcl} \Omega^k(M) & = & \displaystyle \prod_i \Omega^k(M_i) & \qquad \qquad \qquad \qquad \Omega^k_c(M) & = & \displaystyle \bigoplus_i \Omega^k_c(M_i)\\ Z^k(M) & = & \displaystyle \prod_i Z^k(M_i) & \qquad \qquad \qquad \qquad Z^k_c(M) & = & \displaystyle \bigoplus_i Z^k_c(M_i)\\ B^k(M) & = & \displaystyle \prod_i B^k(M_i) & \qquad \qquad \qquad \qquad B^k_c(M) & = & \displaystyle \bigoplus_i B^k_c(M_i)\\ H^k(M) & = & \displaystyle \prod_i H^k(M_i) & \qquad \qquad \qquad \qquad H^k_c(M) & = & \displaystyle \bigoplus_i H^k_c(M_i) \end{array} $$

$$ \begin{array}{rclcrcl} \Omega^k(M) & = & \displaystyle \prod_i \Omega^k(M_i) & \qquad \qquad \qquad \qquad \Omega^k_c(M) & = & \displaystyle \bigoplus_i \Omega^k_c(M_i)\\ Z^k(M) & = & \displaystyle \prod_i Z^k(M_i) & \qquad \qquad \qquad \qquad Z^k_c(M) & = & \displaystyle \bigoplus_i Z^k_c(M_i)\\ B^k(M) & = & \displaystyle \prod_i B^k(M_i) & \qquad \qquad \qquad \qquad B^k_c(M) & = & \displaystyle \bigoplus_i B^k_c(M_i)\\ H^k(M) & = & \displaystyle \prod_i H^k(M_i) & \qquad \qquad \qquad \qquad H^k_c(M) & = & \displaystyle \bigoplus_i H^k_c(M_i) \end{array} $$

This comes directly from the fact that choosing a function in $\displaystyle M=\bigsqcup_i M_i$ is equivalent to choosing one function for each component. The nuance of the direct sum for the cohomology with compact support lies in the fact that a function with compact support in $M$ is zero in all but finitely many components