The oxidation number of C in CO2 is 4.
The oxidation number is basically the count of electrons that atoms in a molecule can share, lose or gain while forming chemical bonds with other atoms of a different element. Oxidation number of an atom is defined as the charge that an atom appears to have on forming ionic bonds with other heteroatoms
Oxygen is assigned the oxidation number -2 in its simple oxides.
x + 2(-2) = 0
x = 4