Rocks formed by the cooling and solidification of molten rocks called magma ejected from beneath…