Answer:
Percent composition = mass of element in the compound/mass of compound × 100
In this case, the mass of the compound is its molar mass.
Percent Composition of N in CO(NH2)2 (urea)
Molar mass CO(NH2)2 = 60.056 g/mol
Mass of N = 2×14.007 g/mol = 28.014 g/mol
%N: 28.014 g/mol/60.056 g/mol × 100 = 46.646%
Percent Composition of N in NH4NO3 (ammonium nitrate)
Molar mass of NH4NO3 = 80.044g/mol
Mass of N = 2×14.007 = 28.014 g/mol
%N: 28.014 g/mol/80.044 g/mol × 100 = 34.998%
Hope this helps, please let me know If I'm wrong.