Simply speaking, an engine is a group of related parts that are assembled in a way to convert energy into motion that, in turn, can be harnessed to do work. Gasoline engines are internal combustion devices that use gasoline as the energy source. Let's build one.
If we were to take a sturdy tin can and spray some gasoline into it, then place a lid over the top and light it through some hole in the side, the explosion would blow the lid quite high into the air. The reason is that the gasoline vapor mixed with air and created a very explosive mixture that in turn created tremendously hot gases that needed to be released. In this case the top blew off.
Now that we know we can move something with the explosion, why not create a mechanical device that can do some work? Therefore, if we hook that can lid to a rod that is connected on its other end to a crankshaft - a device that uses eccentric journals to convert reciprocal motion to rotary motion - and then invert the can and rigidly support it, then the explosion we generate will push the lid and its rod downward, rotating the crankshaft.
Without going into the obvious flaws in the above design, let's move on to how gasoline engines are put together.
Instead of a can we need a strong, rigid cylinder that is drilled into an even stronger piece of metal, usually a heavy casting of iron or aluminum, normally called the cylinder block.
Since we are casting the block, why not design into the casting some passages that can be filled with water to help keep a constant temperature when the engine is running? Also, let's design in some other passages to allow oil to be pumped to lubricate the moving parts.
We can machine the block after casting to create a uniform cylinder of a known dimension. Also, we can drill and tap various holes into the block to accommodate the fasteners that will eventually hold the engine parts together.
The Piston The part that we're going to move with the fuel explosion is the piston. Although older cars used iron pistons, all post-WWII pistons are made of cast or forged aluminum, and are sized to be approximately 10 thousanths of an inch smaller than the cylinder dimension to allow for thermal expansion. Pistons need to be tall enough to avoid tipping sideways as they move up and down the cylinder. They also need to be light to lessen the inertial forces they undergo, so all modern pistons are hollow.
The piston as described above would move quite well down the cylinder bore, but a significant amount of explosive force would "leak" past the sides. In order to limit this problem, pistons are grooved around their circumference with several spaced-apart channels. In these channels are placed spring-steel or iron rings that continuously exert pressure against the cylinder wall, sealing out most of the combustion gases. Most pistons have two compression rings and one oil ring.
About midway down the piston is drilled a precision-sized hole through the diameter to hold the wrist pin, or piston pin.