Let v be the velocity of sound and f be the frequency of the note.
Thus, the wavelength of sound produced is λ=vf
The wavelength of first overtone of open organ pipe is
λo=l+2e=40+2e⇒vf=40+2e
The wavelength of first overtone of closed organ pipe is
λc=43(l+e)=43(31+e)⇒vf=43(31+e)
By eliminating vf from the above two equations, we get
34(40+2e)=31+e⇒120+6e=124+4e⇒e=2cm