Carbon (C) belongs to Group IV A in the periodic table.
Atomic number of C = 6
Electron configuration =
![1s^(2)2s^(2)2p^(2)](https://img.qammunity.org/2019/formulas/chemistry/middle-school/yhj8v2z690e9t6bqzbcgyr26jwtgn7hafn.png)
Oxygen (O) belongs to group VI A in the periodic table
Atomic number of O = 8
Electron configuration =
![1s^(2) 2s^(2) 2p^(4)](https://img.qammunity.org/2019/formulas/chemistry/high-school/k5cy1z1dkftoaj4ymhmzh6p4yshj9dhptl.png)
Based on the electron configurations, the valence shell in C and O have 4 and 6 electrons respectively. As a result carbon is tetravalent, and in CO2 this is satisfied as the C atom forms a double bond with each O atom. Hence the structural formula is:
O=C=O
In addition, there are two lone pairs of electrons on each of the O atoms.