It is a matter of perspective really. If we look at the physics formula: $E=mgh$ we see three letters in this equation.
Suppose we are on earth and we are looking at an object of mass $2$kg. We would like to know the value of $E$ for different values of $h$ (height). So $h$ acts as the variable and $m$ and $g$ are constants. Because we are considering the hypothetical situation were $m$ and $g$ are known. In this particular case $E(h)=2\cdot9.81h$.
Now suppose we are on earth again, and consider dropping something from a height of $3$m.
We would now like to know the value of $E$ for different values of $m$. Now $m$ acts as the variable and $h$ and $g$ are considered constants. Because we are considering the hypothetical situation were $h$ and $g$ are known. In this particular case $E(m)=3\cdot9.81m$.
Likewise we could make $E$ a function of $g$, with $m$ and $h$ constants.
So it all comes down to what you assume to be known information. Any thing that isn't known is unknown/variable, within the context.
Of course if you would like to, you could even see $E$ as a function of three variables: $E(m,g,h)$. It all depends on what qualities of $E$ you want to describe.
For your integral example: we say $\int 2x\,dx=x^2+C$, with $C$ a constant. That is because we say that $\int 2x\,dx$ is a function whose derivative is $2x$.
You can interpret the phrase $\int 2x\,dx=x^2+C$ in the above way, saying something like this:
Suppose we have the function $x^2+1$, then its derivative is $2x$.