#"Oxidation/state"# number is the charge left on the atom of interest, when all the bonding pairs of electrons are broken with the charge assigned to the most electronegative atom.
See here for determination.
Note that this is a conceptual exercise, and the rules for assigning oxidation states are fairly arbitrary and abstract. Note that elements have NEITHER accepted NOR donates electrons, and for a simple redox equation (the one which follows heats our homes, and cooks our food), the oxidation states of the reactants are ZERO:
#stackrel(0)C(s)+stackrel(0)O_2(g)rarrstackrel(+IV)Cstackrel(-II)O_2(g)#
Oxygen typically adopts an oxidation state of #-II# in its compounds (its #"oxides"#, but not #"peroxides"#), i.e. it reflects the #O^(2-)# ion. Carbon can adopt any oxidation state from #-IV# to #+IV#. For instance #stackrel(-IV)CH_4#, #H_3stackrel(-III)C-CH_3#, #H_3stackrel(-III)C-stackrel(-II)CH_2CH_3#, and pervalent #CO_2#. When we encounter a #C-C# chain, we assume that the electrons are shared equally between the carbon atoms of equal electronegativity:
#H_3C-CH_3rarr2xxH_3C*rarr3xxH^(+I) + C^(-III)#.
#(H_3C)_4Crarr4xxH_3C*+:C:rarr3xxH_3C^(-III) + C^(0)#.
I reiterate that this is a CONCEPTUAL exercise. The assignment of oxidation numbers is sometimes useful for the purposes of stoichiometry; it does not reveal much insight as to electronic structure.