How to handle the input parameter in this situation

Hi, I have a problem (maybe stupid one) about the C++. Assume that I have a function y=f(x)=2x. If the input parameter x is int x=2, then the output is 4.However, if I want the input parameter to be x=a+2 (a is another variable), and I want to get the output like y=2a+4 (a relationship between y and a). How can I handle this problem?

Thanks


Remember that the expression 2a+4 has an implied multiplication, so in c++ it would become 2*a+4.

Other than that, it seems straightforward enough - where are you getting stuck exactly?
Topic archived. No new replies allowed.