How do I solve $2^x + x = n$ equation for $x$? I need to solve the equation $$2^x + x = n$$ for $x$ through a programming-based method. Is this possible? If not, then what would be the most efficient way to approximate it?

Newton's method is usually the best numerical method for such problems: it's very simple, converges very fast and it works most of the time. 
To use it define a function $f(x) = 2^x +x - n$ so that the desired solution to your problem is the solution to $f(x) = 0$. Pick a guess $x_0$, say $x_0 = 0$, and the itterate via
$$x_{n+1} = x_n - \frac{f(x_n)}{f'(x_n)}$$
For example if $n=10$ and $x_0 = 0$ then after only $7$ itterations you have the solution to $10$ significant digits. As a convergence criterion you can for example use  $|f(x_n)| < \epsilon$ where $\epsilon$ is some small predefined constant.

${\bf More~above~the~convergence~criterion~in~general}$:
There are many ways to do the convergence criterion and depending on the problem at hand one will be better than the other. Here are some options.
As Claude mentioned below for some functions $|f|$ itself might be unaturally small far away from the desired solution so that monitoring the smallness of $|f(x_n)|$ is not advisable. One cn get around this be considering a criterion like $|x_n - x_{n-1}| < \epsilon$.
Another option is the following: after making the initial guess we first perform $N$ itterations (a 'burn-in') and calculate the initial residual $|f(x_N)|$. Then we continue itterating and define convergence when $\frac{|f(x_k)|}{|f(x_{N}|} < \epsilon$.
One can also consider a combination of $|f(x_k)|$ and $|x_n-x_{n-1}|$ as the criterion. The best advise here is to experiment with the problem-type you have at hand to see for your self what works best.
