let p = # of penguins and b = # of bears
p + b = 18 (both animals have 1 head)
2p + 4b = 50 (bears have 4 feet while penguins have 2)
We have a system of linear equations and can solve with elimination or substitution.
Using elimination,
2(p + b = 18) -> 2p + 2b = 36
Subtract this from the other equation to get
2b = 14 -> b = 7 (7 bears)
p = 18 - b -> p = 11 (11 penguins)