Answers:
16 chickens
35 pigs
========================================================
Step-by-step explanation:
x = number of chickens
y = number of pigs
There are 51 heads, so x+y = 51 which solves to y = 51-x
2x = number of legs just from the chickens (2 legs per chicken)
4y = number of legs just from the pigs (4 legs per pig)
2x+4y = 172 legs total
----------
Plug in y = 51-x and solve for x.
2x+4y = 172
2x+4(51-x) = 172
2x+204-4x = 172
-2x+204 = 172
-2x = 172-204
-2x = -32
x = -32/(-2)
x = 16
Now use this to find y
y = 51-x
y = 51-16
y = 35
Since x = 16 and y = 35, this means there are 16 chickens and 35 pigs.
----------
Check:
x+y = 16+35 = 51 which works
2x+4y = 2*16+4*35 = 172 and that also works.
Both equations are confirmed.