Final answer:
Sedimentary rock is formed through lithification, a process that involves compaction and cementation of sediments. This turns loose sediments into solid rock.
Step-by-step explanation:
The process most directly responsible for the formation of sedimentary rock is lithification, which includes the steps of compaction and cementation. During compaction, sediment is pressed together, reducing the porosity and making it denser, much like pressing down on garbage in a trash can. Cementation occurs when minerals precipitate out of water that is being squeezed out of the pore spaces, acting as a glue and bonding the sediments together. Sedimentary rocks can form from eroded material from pre-existing rocks or from the chemical precipitation of minerals.
Examples of this process at work include the formation of clastic sedimentary rocks (like sandstone), organic sedimentary rocks (like coal), and chemical sedimentary rocks (like salt).