Let $a = 0.98$. Then, we have $ \int a^x dx = \int e^{x \ln a} dx = \frac{e^{x \ln a}}{\ln a} + C = \frac{a^x}{\ln a} + C. $ To evaluate the integral in between, we made the substitution $y = x \ln a$, and used $ \int e^y dy = e^y + C. $ The $C$ is an arbitrary constant. For the purposes of computing the definite integral below, we can ignore the $C$.
So, the average output is given by: $ \frac{1}{x_2 - x_1} \int_{x_1}^{x_2} 100 a^x dx = \left. \frac{1}{x_2-x_1} \cdot \frac{100a^x}{\ln a} \right|_{x_1}^{x_2} = \frac{100}{\ln a} \frac{a^{x_2} - a^{x_1}}{x_2 - x_1}, $ writing it in a slightly nicer form. To make it easy to calculation, we can massage this answer to: $ \frac{100 \ \log_{10} e}{\log_{10} (.98)} \times \frac{0.98^{x_2} - 0.98^{x_1}}{x_2 - x_1} $ Here, $e \approx 2.718\ldots$ is the famous Euler constant.
Note: Be careful with the signs a bit. Since $a < 1$, both $a^{x_2} - a^{x_1}$ and $\log_{10} a$ will turn out to be negative.
Added. The above formula is correct but not that great for numerical computations. I recommend using $ \frac{100 \ \log_{10} e}{\log_{10} (\frac{1}{0.98})} \times \frac{0.98^{x_1} \cdot (1 -0.98^{x_2 - x_1})}{x_2 - x_1} $ instead. You will need to know some standard identities of exponential functions to derive this. Also, note that I have "corrected" the sign problem as well: all the terms will now be positive.
Discrete case. Though not asked by the OP, I will mention how to proceed when you have a discrete sequence of outputs, rather than a continuous function $f(x)$ (like, $a^x$). Specifically, imagine that the output in the starting year is $100$, and every subsequent year, this drops to $98 \%$ of the previous year.
In this case, the outputs for the first $40$ years form a geometric sequence $100, 100 a, 100 a^2, \ldots, 100 a^{40-1}$. Suppose you want to calculate the average of the outputs of all years between $n_1$th and $n_2$th year (both endpoints included). This is given by: $ \frac{100 a^{n_1 - 1} + 100 a^{n_1 + 1 - 1} + \ldots + 100 a^{n_2 - 1}}{n_2 - n_1 + 1}. $ In this case, the numerator can be summed by geometric series formula. I will only mention the final answer without going into the details: $ \frac{100}{1-a} \times \frac{a^{n_1-1} \cdot (1 - a^{n_2 - n_1 +1})}{n_2 - n_1 +1}. $ Notice the similarities between the two answers. Plugging in $a = 0.98$, we get: $ 5000 \times \frac{0.98^{n_1-1} \cdot (1 - 0.98^{n_2 - n_1 +1})}{n_2 - n_1 +1}. $