The sum of the oxidation numbers always equals the charge on the ion. If we deal with a neutral molecule, the oxidation numbers of the constituent atoms must sum to ZERO.
Most of the time, hydrogen, in its compounds has an oxidation state of +I, i.e. it is conceived to have donated 1 electron, and we treat it as H+; and oxygen in its compounds has an oxidation state of −II, it is conceived to have accepted 2 electrons, and we treat it as O2−. (Peroxides and hydrides are the exceptions!).
So for ammonium biphosphate, (NH4)2HPO4, the oxidation number of hydrogen is +I, and that of oxygen −II; with some simple algebra, I can assign a −III state to nitrogen, and a +V state to phosphorus. If you add these oxidation states up: 2×−III+8×I+V−4×II+I=0 you get zero as is required for a neutral compound or salt.
And for XeOF4, the oxidation number of Xe=VI+(O=−II,F=−I), for C8H10, the carbon has an average oxidation number of −108 (the terminal carbons are −III, and the methylene, CH2, carbons are −II, vinyl, =CH carbons are −I; the average is −108.
And for BaSO4, Ba=+II,S=+VI,andO=−II.
I have thrown a lot of facts and calculations at you. Mind you, you posed an open-ended question, which required a lot of background. The point to learn is that the sum of the oxidation numbers equals the charge on the ion. I think these calculations are well within the grasp of a 2nd year chemistry student. If there are further questions, post them, and someone will help you.