For example, granite is a rock composed of interlocking crystals of quartz, feldspar, mica, and a mineral called hornblende. Sandstone is a rock composed of grains of the same minerals that make up granite. Sandstone, by the way, is just sand that has turned into rock. In other words, it has lithified. This molten rock in the Earth's interior is termed Magma.
Sedimentary rocks form by lithification of sediment at the Earth's surface.
The Rock Cycle - Processes at or near the Earth's surface constantly work to change existing rocks and form new ones. There is a continuous cycling of rock material, which we term the rock cycle. No single rock has remained unchanged since the Earth was first formed. Those rocks may be altered by wind, rain, and other weathering processes at Earth's surface. The products of those alteration processes are then deposited as sediment and eventually undergo lithification to become sedimentary rocks.