Let the speed of the stream be v km/h.
Given that, a person rowing in still water = 5 km/h
The speed of a person rowing in downstream = (5 + v) km/hr
and the speed of a person has rowing in upstream = (5 - v) km/hr
Now, the person taken time to cover 40 km downstream,
and the person has taken time to cover 40 km upstream,
Hence, the speed of the stream is 2.5 km/h.