Yes, zoos affect the animals life span. According to study of more than 50 mammal species, it was found that in over 80 percent of cases, zoo animals can live longer than when they live in the wild.
The reason is that zoos provide protection against a number of conditions as predation, infections and diseases.
But in animals like elephants,they live longer in the wild.