1

This is my program. I dont know what to do next because I dont know what is invalid indirection. The error is found from line 46 to 52.

#include<iostream.h>
#include<conio.h>
#include<math.h>
#include<stdio.h>


int main()
{
int d, c;

double fx, fx1, fx2, fx3, fd, fd1, fd2, fd3, x, xi, e, y, er;

double in[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0};

clrscr();


cout << "\n\nEnter degree: ";

cin >> d;

if(d == 9)
{
    cout << "\n\nThis is only limited up to the dehree of 8.";
}

else if(d == 0)
{
    cout << "\n\nCannot solve equation. There is no variable present.";
}

else
{

    for(c = d; c >= 0; c--)
    {
        cout << "\nCoeff for x^" << c << " term: ";
        cin >> in[c];
    }

    cout << "\n\nEnter xi = ";
    cin >> x;

    do
    {
        **fx1 = (c[8] * pow(x,8)) + (c[7] * pow(x,7)) + (c[6] * pow(x,6));
        fx2 = (c[5] * pow(x,5)) + (c[4] * pow(x,4)) + (c[3] * pow(x,3));
        fx3 = (c[2] * pow(x,2)) + (c[1] * x) + c[0];
        fx = (fx1 + fx2 + fx3);

        fd1 = (d * c[0] * pow(x, d-1)) + ((d-1) * c[1] * pow(x, d-2)) + ((d-2) * c[2] * pow(x, d-3));
        fd2 = ((d-3) * c[3] * pow(x, d-4)) + ((d-4) * c[4] * pow(x, d-5)) + ((d-5) * c[5] * pow(x, d-6));
        fd3 = ((d-6) * c[6] * pow(x, d-7)) + (c[7]);**

        fd = (fd1 + fd2 + fd3);

        y = x;

        x = (x - (fx/fd));

        e = x - y;

        if(e >=0)
        {
            er = e;
        }

        else
        {
            er = -(e);
        }
    }while(er > 0.0000000001);

    cout << "\n\nThe root of the equation is " << x << ".";



}



getch();


return 0;
}
Kijewski
  • 25,517
  • 12
  • 101
  • 143
  • What compiler are you using? You've got `cout` littered all over without qualifying its namespace or a `using namespace std;` at the top of the file. At least make an effort to get your code to compile before posting it here. – Praetorian Jul 24 '11 at 06:23
  • Also, if you want to limit the value of `d` so that `0 < d < 9` you do not just compare it to `0` and `9`, you need to use `d <= 0` and `d > 8` in the checks. I suggest you pick up a book on C++. – Praetorian Jul 24 '11 at 06:25
  • im using turbo c. our teacher is using cout so i just follow. thanks for you help.:) – Joi Lynn Marie Jover Jul 24 '11 at 06:35
  • -1 for using ** to point at a line! – Thomas Padron-McCarthy Jul 24 '11 at 06:53

3 Answers3

4

You're seeing this because you're using c, which is an integer, as an array/pointer. The indirection error occurs because you're incorrectly dereferencing something that is not a pointer.

Josh Matthews
  • 12,816
  • 7
  • 36
  • 39
4

makes sense, variable c is not an array but an int, but there are c[8], c[6], etc.

Murali VP
  • 6,198
  • 4
  • 28
  • 36
1

you must use same array name i.e in[] instead of c[] and also remove ** before every variable.