Step 1: Write the fundamental frequency of an open organ pipe.
For an open organ pipe, the fundamental frequency is
\[
f=\frac{v}{2L}
\]
where \(v\) is the speed of sound and \(L\) is the length of the pipe.
Step 2: Find the beat frequency.
The pipes give \(40\) beats in \(10\,\text{s}\).
So, beat frequency is
\[
f_b=\frac{40}{10}
\]
\[
f_b=4\,\text{Hz}
\]
Step 3: Write frequencies of the two pipes.
For the first pipe,
\[
L_1=50\,\text{cm}=0.50\,\text{m}
\]
So,
\[
f_1=\frac{v}{2(0.50)}
\]
\[
f_1=v
\]
For the second pipe,
\[
L_2=51\,\text{cm}=0.51\,\text{m}
\]
So,
\[
f_2=\frac{v}{2(0.51)}
\]
\[
f_2=\frac{v}{1.02}
\]
Step 4: Use the beat frequency formula.
Beat frequency is
\[
f_b=|f_1-f_2|
\]
Thus,
\[
4=\left|v-\frac{v}{1.02}\right|
\]
\[
4=v\left(1-\frac{1}{1.02}\right)
\]
\[
4=v\left(\frac{1.02-1}{1.02}\right)
\]
\[
4=v\left(\frac{0.02}{1.02}\right)
\]
\[
4=v\left(\frac{2}{102}\right)
\]
\[
4=v\left(\frac{1}{51}\right)
\]
\[
v=204\,\text{ms}^{-1}
\]
Step 5: Final conclusion.
Hence, the speed of sound in this medium is
\[
\boxed{204\,\text{ms}^{-1}}
\]