Solution:
Concept: The frequency heard is the number of wave crests that pass the listener each second. It equals the speed of the waves relative to the listener divided by the wavelength in the air.
Step 1 — Set up the problem. Let a source S of frequency f and a listener L lie on one line. The speed of sound in still air is V. The velocities of the source and the listener, Vs and Vl, are taken positive in the direction from S to L (the direction in which the sound travels to the listener) and negative against it.

Step 2 — Find the wavelength sent out by the moving source. In one period T=f1, a crest travels a distance VT towards L. In the same time the source moves VsT in the same direction and then sends out the next crest. So the two crests are separated by:
λ′=VT−VsT
λ′=fV−Vs
The figure shows these crests, crowded in front of the moving source and spread out behind it.

Step 3 — Find the speed of the waves relative to the listener. The waves move at V through the air, and the listener moves at Vl in the same direction, so the waves pass the listener at:
Vrel=V−Vl
Step 4 — Find the apparent frequency. The number of crests passing the listener each second is this relative speed divided by the wavelength:
f′=λ′V−Vl
f′=(V−Vs)/fV−Vl
f′=(V−VsV−Vl)f
This is the general expression.
Step 5 — Case (i): listener at rest, source moving. We put Vl=0:
f′=(V−VsV)f
For a source approaching the listener (Vs positive) the frequency rises; for a source moving away we write Vs=−vs, and f′=(V+vsV)f, which is lower.
Step 6 — Case (ii): listener moving, source at rest. We put Vs=0:
f′=(VV−Vl)f
For a listener moving towards the source, Vl=−vl, and f′=(VV+vl)f, which is higher; for one moving away, f′=(VV−vl)f, which is lower.
Step 7 — Case (iii): both moving. The general expression applies directly:
f′=(V−VsV−Vl)f
For example, when they approach each other with speeds vs and vl, Vs=+vs and Vl=−vl, so f′=(V−vsV+vl)f.
Watch out: The formula holds only while the source and the listener move slower than sound and the medium is still; with a wind Vw along the sound, replace V by V+Vw.
Therefore, f′=(V−VsV−Vl)f; it gives (i) (V−VsV)f, (ii) (VV−Vl)f and (iii) (V−VsV−Vl)f.