Carbon contains four valence electrons and oxygen atoms contain six. These are the electrons of an atom that can participate in the formation of chemical bonds between atoms. A molecule of carbon dioxide has one carbon atom and two oxygen atoms, held together by covalent bonds. The carbon is doubly bonded to two oxygen atoms. An octet of valence electrons is a stable arrangement. Therefore, the carbon atom is in the center, with two hydrogen atoms on either side. It is a linear molecule. Each oxygen shares two of its electrons with the carbon atom which already has four valence electrons of its own, making a total of 8.