Before discussing this in more detail, however, let us see why this statement is surprising. As with the example of the ice cube melting on a hot day, nothing from energy conservation would prevent work from being completely converted into other forms of energy, and indeed such total conversion can happen for energies other than heat. For example, a ball released from rest which falls to the ground has all gravitational potential energy at the top and all kinetic energy at the bottom - the potential energy at the top thus gets completely converted to kinetic energy at the bottom. Or if the ball is connected to a rope and pulley of some sort, its gravitational potential energy can be converted into useful work (churning butter for example). Although in practice some of the potential energy will be lost to friction, there is no reason in principle that all the potential energy cannot be converted into work. If we go back to our analogy between heat flowing from hot to cold and an object running down hill, we can understand that in principle, instead of going into kinetic energy to raise the temperature of the cooler substance heat can be harnessed to do useful work. In this context the second law makes the very surprising statement that some of the heat energy must always be lost, so that the conversion from heat to work is never 100% efficient. Note, however, that this form of the 2nd law places no restriction on converting other forms of energy into heat - it is the conversion of heat into other forms of energy that turns out never to be 100% efficient, even in principle.
An machine which converts heat into other forms of energy is called a heat engine; the generic operation, in accordance with the 2nd law, is pictured below.
The important aspect here is that some ``waste heat'' is always expelled into the cooler reservoir; no heat engine could operate without such expulsion. This is why, for example, one notices in the winter near a steam powered electrical generating plant that nearby ice on a river is melted - this comes from the waste heat of the plant being expelled into the river.
One can show that there is an ideal maximum efficiency present for the conversion of heat into external work: this is
where the temperatures are expressed in the Kelvin scale. It is important to note that this is an ideal efficiency - real engines also lose some efficiency due to friction, etc., but this is above this theoretical limit. Thus, a heat engine would operate with 100% efficiency in converting heat into useful work only if the cool reservoir was at 0 K ( -273 o), which is not possible.
For example, a steam powered electrical generating plant which operates between 500 K and 300 K (room temperature) has a maximum efficiency of 40%. Similar considerations hold for an internal combustion engine, the basic operation of which is illustrated below.
In this segment of the cycle, the fuel mixture explodes, either from a spark plug for a gas engine or from the high pressure for a diesel engine. This drives the piston downwards, which subsequently turns the crankshaft and eventually the wheels - this is the part which converts the energy of heat into useful work. The piston then rises, expelling the exhaust gases which carry away the waste heat. The cycle then goes on to draw in more fuel mixture to repeat the cycle. The major point here is that the exhaust gases carry with them excess heat which could not be converted into useful work.