assuming that you have 100 grams of sample, each of the values is the grams of each atom.
first we need to convert each grams to moles using their molar mass
carbon-> 49.5 grams (1 mol/ 12.0 g)= 4.13 moles
hydrogen-> 5.1 grams (1 mol/ 1.01 g)= 5.05 moles
nirogen-> 28.9 grams (1 mol/ 14.0 g)= 2.06 moles
oxygen->16.5 grams (1 mol/ 16.0 g)= 1.03 moles
then you need to divide each value by the smallest, and if you don't get the whole number, you need to multiply
carbon-> 4.13/1.03= 4
hydrogen->5.05/ 1.03= 5
nitrogen-> 2.06/ 1.03= 2
oxygen-> 1.03/ 1.03= 1
empirical formula-> C4H5N2O
to find the molecular formula, you can find the molar mass of the empirical formula and see what is the ratio of the given molar mass by the question.
molar mass of C4H5N2O = 97.1 g/ mol
195/ 97.1= 2
the molecular formula is twice the empirical-> C8H10N4O2