Let the time taken be 't' hours.
average speed= total distance covered/total time taken
distance covered with 80km/h speed.
80*t/2=d1
40t=d1
distance covered with 40 km/h speed
40* t /2=D2
20t=D2
average speed of car= (40t+ 20t)/t
60km/h is the average speed