It's not really easy to determine the ox-num of elements, but I hope that this helps:
Draw the structure of the molecule and put all bonding electron pairs to the most electronegative atom.
e.g. O=C=O => O is more electronegative
=> |O| + C + |O| __ __
Oxygen has 6 electrons in it's elementar state, in this case the oxygen atom has 8 electrons (2 electrons more), so it has the oxidation number -2 (an electron has a negative charge). You have to compare the number of electrons in the elementar state and the number of electrons in the molecule (after putting the bonding electrons to the more electronegative atom).
Carbon has 4 electrons in it's elementar state, in this case no electron is associated to carbon => 4 electrons are missing => ox-num is +4
Hint: The most common ox-num for Oxygen is -2 (except in peroxides, hyperoxides and OF2
) and Hydrogen has always the ox-num +1 (excpt in metal hydrides)
I hope that you understand my explanation....