Is it possible to calculate $\int_{0}^{\pi}(a+\cos{\theta})^nd\theta$, where $a$ is a nonzero integer? I have tried to answer by taking change the variable $\theta$ to $\theta/2$, so the integration is now over unit circle, then I have taken $z=e^{i\theta}$. Now I tried to use residue formula for integration, but I failed.

If your integral is $J_n$, the exponential generating function of the sequence $J_n$ is
$$ \eqalign{g(x) &= \sum_{n=0}^\infty \int_0^\pi \frac{(a+\cos(\theta))^n x^n}{n!}\; d\theta \cr
 &= \int_0^\pi \exp((a + \cos(\theta) x)\; d\theta\cr
&= \pi e^{ax} I_0(x)}$$
where $I_0$ is a modified Bessel function.  Since 
$$ e^{ax} = \sum_{j=0}^\infty \frac{a^j x^j}{j!}$$
and 
$$ I_0(x) = \sum_{k=0}^\infty \frac{x^{2k}}{4^k k!^2}$$
we get
$$ J_n = \pi n!\sum_{k=0}^{\lfloor n/2 \rfloor} \frac{a^{n-2k}}{4^k (n-2k)! k!^2}$$
