Answer: 7 chickens and 11 goats
============================================================
Work Shown
c = number of chickens
18-c = number of goats
These two expressions add to 18 heads total.
2c = number of feet from the chicken
4(18-c) = number of feet from the goats
Add up those subtotals to get a grand total of 58 legs.
2c+4(18-c) = 58
2c+72-4c = 58
-2c+72 = 58
-2c = 58-72
-2c = -14
c = -14/(-2)
c = 7 chickens
18-c = 18-7 = 11 goats
---------
Check:
head count: 7+11 = 18 heads total
feet count: 2*7+4*11 = 58 feet total
We have confirmed both answers