So the total for dogs (bottom left box) is 47
17 of them had a cat so the top left box is 17
47-17=30 so 30 have a dog but no cat (left column, middle row)
24 cat but no dog (middle column, top row)
9 no cat no dog (very middle box)
Total no dog= 24 + 9 = 33
Total cat (top right) = 17 + 24 = 41
Total no cat (right column, middle row) = 9 + 30 = 39
Hope this make sense :)