Cost price of 100 articles = $4000. => $ 40 per article
He sold 20 of them at a gain of 5%. So the selling price = 40x105/100 = $ 42 per article
Selling price of 20 article = $ 42 x 20 = $ 840
For 20 % gain on whole the total selling price = $ 4000 x120/100 = $ 4800
Total Selling price of remianing 80 articles = $ 4800 - $ 840 = $ 3960
Selling price of ramaining articles = $ 3960/80 = $ 49.5 per article
Gain % = (49.5-40)x100/40 = 23.75 %