Igneous rocks are formed through the solidification and cooling of molten magma or lava. This process can occur either beneath the Earth's surface (intrusive igneous rocks) or on the surface (extrusive igneous rocks). Igneous rocks are characterized by their crystalline structure and can have a variety of textures, such as fine-grained or coarse-grained. Examples of igneous rocks include granite, basalt, and obsidian. Sedimentary rocks, on the other hand, are formed through the accumulation and compaction of sediments, while metamorphic rocks are formed through the alteration of pre-existing rocks due to high heat and pressure.