Sound velocities of cementite Fe3C have been measured up to 1.5 Mbar and at 300 K in a diamond anvil cell using the nuclear resonant inelastic X-ray scattering (NRIXS) technique. From the partial phonon density of states (pDOS) and equation of state (EOS) of Fe3C, we derived its elastic parameters including shear modulus, compressional (VP) and shear-wave (VS) velocities to core pressures. A pressure-induced spin-pairing transition in the powdered Fe3C sample was found to occur gradually between 10 and 50 GPa by the X-ray Emission Spectroscopy (XES) measurements. Following the completion of the spin-pairing transition, the VP and VS of low-spin Fe3C increased with pressure at a markedly lower rate than its high-spin counterpart. Our results suggest that the incorporation of carbon in solid iron to form iron carbide phases, Fe3C and Fe7C3, could effectively lower the VS but respectively raise the Poisson's ratio by 0.05 and 0.07 to approach the seismically observed values for the Earth's inner core. The comparison with the preliminary reference Earth model (PREM) implies that an inner core composition containing iron and its carbon-rich alloys can satisfactorily explain the observed seismic properties of the inner core.