The answer would depend on which gallon you meant: the Imperial gallon or the US gallon. This is one one the main problems with the old system(s). A gallon is not the same on different sides of the Atlantic!
40 gallons is approximately equal to 151.4 liters.
20 gallons is 320 cups and 40 cups is 2.5 gallons.
40 US gallons = 151.4 litres while 40 Imperial gallons = 181.8 litres.
40 liters is equal to approximately 10.57 gallons.
40 gallons = 151.4 liters
10 gallons = 40 quarts
5 gallons=40 pints
At 8 pints to the gallon, that would be 40 pints.
(40 quarts) divided by (4 quarts per gallon) = 10gallons
8.8 Imp Galls
5 gallons
40 quarts or 80 pints