Answer: the farmer has 19 cows.
Step-by-step explanation:
Let x represent the number of cows that the farmer has.
Let y represent the number of chicken that the farmer has.
The farmer has a total of 40 animals. It means that
x + y = 40
A cow has 4 legs. A chicken has 2 legs. One day he counts the legs of all his animals and realizes he has a total of 118 legs. It means that
4x + 2y = 118- - - - - - - - 1
Substituting x = 40 - y into equation 1, it becomes
4(40 - y) + 2y = 118
160 - 4y + 2y = 118
- 4y + 2y = 118 - 160
- 2y = - 42
y = - 42/ - 2
y = 21
x = 40 - y = 40 - 21
x = 19