Step 1: Convert speeds into SI units.
Speed of train \(A\) is
\[
72\,\text{km h}^{-1}=72\times \frac{5}{18}=20\,\text{m s}^{-1}
\]
Speed of train \(B\) is
\[
36\,\text{km h}^{-1}=36\times \frac{5}{18}=10\,\text{m s}^{-1}
\]
Thus,
\[
v_s=20\,\text{m s}^{-1}
\]
and
\[
v_o=10\,\text{m s}^{-1}
\]
Step 2: Apply Doppler effect formula.
Since the source and observer are moving towards each other, apparent frequency is
\[
f' = f\left(\frac{v+v_o}{v-v_s}\right)
\]
Here,
\[
f=640\,\text{Hz},\quad v=340\,\text{m s}^{-1}
\]
Therefore,
\[
f'=640\left(\frac{340+10}{340-20}\right)
\]
\[
f'=640\left(\frac{350}{320}\right)
\]
\[
f'=640\times \frac{35}{32}
\]
\[
f'=20\times 35
\]
\[
f'=700\,\text{Hz}
\]
Step 3: Final conclusion.
Therefore, the frequency heard by the passenger in train \(B\) is
\[
\boxed{700\,\text{Hz}}
\]