Answer:
When magma solidifies it forms igneous rocks. If a pre-existing rock is exposed to extreme heat or pressure its physical properties can change, forming a metamorphic rock. Rocks derived from the weathered grains of other pre-existing rocks through lithification are sedimentary rocks.
Explanation:
The naturally occurring structure that is formed on the Earth's crust and is composed of a single mineral or an aggregate of several minerals is known as a rock. The classification of rocks on the basis of their formation is igneous rocks, sedimentary rocks, and metamorphic rocks.
Igneous rocks: They are formed by the slow or rapid cooling and then solidification of molten magma on the Earth's crust or seabed. The two types of igneous rocks are intrusive igneous rocks, which contain large crystals formed by the slow cooling of magma below the Earth's surface (granite, gabbro, diorite, pegmatite, etc) and extrusive igneous rocks, which contain small crystals formed by the fast cooling of magma that reached on the Earth's surface (basalt, obsidian, pumice, tuff, etc).
Sedimentary rocks: They are formed by the accumulation and lithification (compaction and cementation of accumulated sediments) of sediments created from the weathering of existing rocks or fragments of minerals and organisms over time. The different types of sedimentary rocks are clastic sedimentary rocks, which are formed from the fragments of other weathering rocks (conglomerate, sandstone, mudstone, siltstone, etc), chemical sedimentary rocks, formed from the dissolved materials precipitated from solution (rock salt, oolitic limestone, gypsum, etc) and organic sedimentary rocks, created from the accumulation of debris formed from plants or animals (limestones, coal, dolomites, etc).
Metamorphic rocks: They are transformed rocks formed from the existing rocks that are subjected to large pressures (regional or dynamic metamorphism) and temperatures (contact or thermal metamorphism). The basic types of metamorphic rocks are foliated metamorphic rocks that have a layered or banded appearance (gneiss, schist, etc) and non-foliated metamorphic rocks that do not have a layered (quartzite, hornfels, marble, etc).