Thermal efficiency is a measure of the output energy divided by the input energy in a system. It must be between 0% and 100%. A level of 100% would mean that all energy put into a system comes out, albeit in a different form. Heat engines and refrigerators both have associated thermal efficiencies, though they are trying to accomplish opposite objectives. Real-world thermal efficiencies generally fall significantly below 100% due to a variety of reasons.
In a gasoline engine, input energy is stored in the chemical bonds of a hydrocarbon fuel. A hydrocarbon molecule consists entirely of hydrogen and carbon. When these molecules are combined with oxygen, they can chemically react and form carbon monoxide and water; in essence, the hydrocarbon molecule is split up and combined with oxygen atoms. The part of this reaction that is useful to an engine, though, is the heat that is released. Heat released from gasoline combustion is the relevant input energy in thermal efficiency.
The output energy in the efficiency calculation of an engine is not heat, but mechanical work. In physics, work is the amount of energy transferred by a force acting over a distance. Pushing a box over carpet a certain distance requires a finite amount of work; this is equal to the product of the distance moved and the average force exerted. In the same way, a gasoline engine does work when it moves the wheels of a car.
In the case of a refrigerator or air conditioner, the heat-work relationship is reversed. The desired result in this situation is to remove heat from a system and dump it into the exterior environment. The available input, therefore, is mechanical work, which is often provided by an electrically-powered compressor. Calculating the efficiency, however, still requires dividing the output energy by the input energy. The difference from a gasoline engine, of course, is that the output is heat and the input is work.
A typical automobile engine has a thermal efficiency of less than 35%. This number seems low for two important reasons. First of all, there is a theoretical upper limit on the thermal efficiency of any heat engine that has to do with the system temperature versus the environment temperature. The higher the difference in temperature, the higher the maximum efficiency an ideal, frictionless engine can achieve. This is called the Carnot efficiency.
The second reason car engines have an apparently low efficiency is that engines cannot be made to behave in an ideal fashion. Friction between moving parts constantly tends to slow down the engine. Some heat escapes from the combustion chamber and becomes useless to the engine. Fuel does not always burn at the highest temperature reached, reducing the amount of heat released. For these reasons, the thermal efficiency in real-world devices tends to be far below 100%.