If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Trying to use C++ to solve a math problem

I had this riddle to solve and I know the answer to be
around ~ 12.31185723778668829963

What steps can i go about to get this to compute this problem without doing the work for this problem and other problems similar to this?
I'm not used to c++ and just need help with initialization and outputting the answer I got.

Re: Trying to use C++ to solve a math problem

I'm not used to c++ and just need help with initialization and outputting the answer I got.

Use variables and number literals of type double throughout.

Declare double variables like this,

double a=40.0;

or several on one line

double b=30.0, c=10.0;

All double literals should have a . in them otherwise things may go wrong. For example 1/3 may evaluate to 0 because you may get integer division whereas 1.0/3.0 will evaluate to 0.3333333333..... as it should.

To output a number you can do,

std::cout << a << std::endl;

or several like

std::cout << b << ", " << c << std::endl;

To calculate powers you need to use the pow function (or multiply the number several times with itself like say x^3 = x*x*x).

* The Perfect Platform for Game Developers: Android
Developing rich, high performance Android games from the ground up is a daunting task. Intel has provided Android developers with a number of tools that can be leveraged by Android game developers.

* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.