Given, $\int e^{x}\left(\frac{x+2}{x+4}\right)^{2} d x=f(x)+c$
Now, $\int e^{x}\left(\frac{x+2}{x+4}\right)^{2} d x=\int e^{x}\left(\frac{x^{2}+4+4 x}{(x+4)^{2}}\right) d x$
$ =\int e^{x}\left(\frac{x}{x+4}+\frac{4}{(x+4)^{2}}\right) d x$
Let $g(x)=\frac{x}{(x+4)}$, then $g'(x)=\frac{4}{(x+4)^{2}}$
$=\int e^{x}\left\{g(x)+g^{\prime}(x)\right\} d x$
$ =e^{x} g(x)+c=e^{x}\left(\frac{x}{x+4}\right)+c$
$\therefore f(x)=\frac{x e^{x}}{x+4}$