A: X-rays and gamma rays are both part of the electromagnetic spectrum, with both having high frequencies and short wavelengths. Of the two, gamma rays have the shortest wavelength and highest frequency; so while both X rays and gamma rays have high amounts of energy, gamma rays are the most energetic of them all.
Now we can better understand their uses. Gamma rays being so high-energy makes them good at penetrating through many kinds of materials - including body cells. That’s why they are used to kill off cancerous cells in the body as a way of treating cancers.
X rays are slightly less energetic, but are still good at penetrating through the human body. And not only that, they attenuate, or lose their energy at different amounts when passing through muscle, tissue or bone (attenuating the most through bone). That helps X rays in being used for body-imaging, wherein the skeleton is viewed with much ease.