They are different modalities and are used for different things, so it isn't always possible to compare them directly. You can't always use an ultrasound *instead* of an X-ray or vice versa, in other words.
Ultrasound does a good job of showing fluid collections and things of different densities that are relatively close to the surface. Certain high-tech kinds of ultrasound are also very useful for seeing blood flow (Doppler) and for seeing anything that you want to observe in motion (heart valves opening and closing, a fetus's hand moving). The resolution is relatively poor--it takes some skill to know what you're looking at when you see an ultrasound. They use sound waves, which are very safe. However, they don't get great penetration, so it can be difficult to get the view you need in an obese patient, and they will not penetrate bone, so you can't use them to, say, examine the brain (except in very young children whose 'soft spots' haven't closed yet). They are also limited in scope--you can't get an ultrasound of the whole chest.
X-rays are very penetrating and the radiation is not particularly good for you--there's no harm in a single X-ray, but we do try to limit how many you get and that is the reason that all X-ray techs will be wearing lead aprons. The clarity of a good X-ray is excellent, but just like any other picture, getting a good one does depend to some extent on having a good "photographer". A bad X-ray, like a blurry photo, is useless for diagnosis. To examine bony structures, overview of organs, to see air or fluid collections in a large portion of the body (like the whole thorax or the whole abdomen), they are the best first image to order. But you can't use them to see some very subtle things, and you can't use them on a woman who is pregnant (if we really must get, say, a chest X-ray on a pregnant woman, it can be done, but they will protect the fetus by using the lead aprons) and they only show one moment in time, so they are of no use in seeing how things are flowing or moving.
That's about the best general answer I can come up with. Sorry it got so long. ;-)
4th year medical student.