C++. Could anyone help me find error in my code for solving equation with simple iterations method? i getting solution like -1.#IND00
<p><br />
I am trying to solve the next equation with C++ help: 3sin(sqrt(x)) + 0.35x - 3.8 = 0<br />
The area with solution is [2, 3]<br /><br />
I wrote next code:</p>

<pre><code>float f(float x)
{
    return (3 * sin(sqrt(x))) + (0.35 * x) - 3.8; //this is equation i am trying to solve
}

float g(float x, float(*f_ptr)(float)) 
{
    const float CONST = 0.1f; //const used to solve equation

    return CONST * f_ptr(x) + x;
}

void Task4_CalculateSomething()
{
    float x0, //starting aproximation
        xk, //current aproximation
        a = 2, //left barrier
        b = 3, //right barrier
        epsilon = 0.001; //allowed error

    const float REAL_SOLUTION = 2.2985; //real solution of selected equation

    printf("Setup starting aproximation: ");
    scanf("%f", &amp;x0);

    do
    {
        xk = g(x0, f); //calc current aproximation

        if (fabs(xk - x0) &lt; epsilon) //if Xn - Xn-1 fits the allowed error, the solution must be found
            break; //then we exit
        else
            x0 = xk; //else reset x values
    }
    while (fabs(a - x0) &gt; epsilon &amp;&amp; fabs(b - x0) &gt; epsilon);

    printf("Found solution: %f\nReal solution: %f\n", xk, REAL_SOLUTION);
}
</code></pre>

<p>But it gives me weird results like -1.#IND00 which i don't even know what is it.<br />
And i can't find any error there...</p>
