Rocks can be classified into three main types based on their formation:
1) Igneous rocks form from the cooling and solidification of magma either below or above the Earth's surface.
2) Metamorphic rocks form from the alteration of existing rocks by heat, pressure, and chemical reactions in Earth's crust.
3) Sedimentary rocks form from the compaction and cementation of sediments like sand and shells. They provide information about past surface conditions.