What is the formal charge on each atom in #CO_2#?
SIDE NOTE: the actual structure of the carbon dioxide molecule is a hybrid between these three structures, but I'll just show you each of them separate because I don't want the answer to become too long.
The carbon dioxide molecule has a total of 16 valence electrons - 4 from the carbon atom and 6 from each of the two oxygen atoms, all of which being accounted for in the three Lewis structures above.
The easiest way to assign a formal charge on an atom is to compare the number of valence electrons that atom has with how many electrons it "gets" in a molecule - assuming bond electrons are shared equally at all times regardless of electronegativity.
Let's start with the first Lewis structure. Carbon forms 4 bonds, which means it gets 4 electrons - 1 from each bond. Since carbon has 4 valence electrons, its formal charge will be zero.
The same is true for both oxygen atoms. Both of them form 2 bonds, which means they get 2 electrons. In addition to these electrons, they both have 2 lone pairs; this brings the total number of electrons an oxygen atom gets to 6 (2 + 4). Since oxygen has 6 valence electrons, it will have a zero formal charge.
Moving on to the second Lewis structure. Carbon is in the same position it was earlier - it forms 4 bonds
This means that it will get 5 electrons - 3 from the bonds and 2 from the lone pair; now it has one less electron than it "needs", i.e. one less than its valence electrons. This will result in a (+1) formal charge.
The oxygen on the right forms 1 bond with the carbon and has 3 lone pairs, for a total of 7 electrons; since it has one more electron than it needs, it will automatically have a (-1) formal charge.
The third structure is identical to the second with respect to formal charges, but this time the oxygen on the left will get a (-1) formal charge and the one on the right a (+1) formal charge.