bestfitcircle.c:46: error: called object is not a function

This is a discussion on bestfitcircle.c:46: error: called object is not a function within the C Programming forums, part of the General Programming Boards category; bestfitcircle.c:46: error: called object is not a function That is the error message that I get for the following C ...

  1. #1
    Registered User
    Join Date
    Aug 2008
    Posts
    15

    bestfitcircle.c:46: error: called object is not a function

    bestfitcircle.c:46: error: called object is not a function
    That is the error message that I get for the following C program.

    Code:
    #include <stdio.h>
    #include <math.h>
    
    main() {
    int count, points, x_sum = 0, y_sum = 0;
    float x_avg, y_avg, sigma[7], k_prime, h_prime, h, k, r = 0;
    for(count = 0; count < 7; count++){
    sigma[count] = 0;
    }
    
    printf("How many points?\n");
    scanf("%d", &points);
    float x[points], y[points], x_prime[points], y_prime[points];
    
    for(count = 0; count < points; count++){
    printf("Insert x of point #%d:\n", count+1);
    scanf("%f", &x[count]);
    printf("Insert y of point #%d:\n", count+1);
    scanf("%f", &y[count]);
    }
    
    for(count = 0; count < points; count++){
    x_sum = x_sum + x[count];
    y_sum = y_sum + y[count];
    }
    
    x_avg = x_sum / points;
    y_avg = y_sum / points;
    
    for(count = 0; count < points; count++){
    x_prime[count] = x[count] - x_avg;
    y_prime[count] = y[count] - y_avg;
    }
    
    for(count = 0; count < points; count++){
    sigma[0] = sigma[0] + pow(x_prime[count],2);
    sigma[1] = sigma[1] + (x_prime[count] * y_prime[count]);
    sigma[2] = sigma[2] + pow(x_prime[count],3);
    sigma[3] = sigma[3] + (x_prime[count] * pow(y_prime[count],2));
    sigma[4] = sigma[4] + pow(y_prime[count],2);
    sigma[5] = sigma[5] + (y_prime[count] * pow(x_prime[count],2));
    sigma[6] = sigma[6] + pow(y_prime[count],3);
    }
    
    k_prime = ((sigma[0] * (sigma[5] + sigma[6])) + (sigma[1] * (sigma[2] + sigma[3]))) / (2 * ((sigma[4] * sigma[0]) - (sigma[1] * sigma[1])));
    h_prime = (((1 / 2)(sigma[2] + sigma[3])) - (k_prime * sigma[1])) / sigma[0];
    k = k_prime + y_avg;
    h = h_prime + x_avg;
    
    for(count = 0; count < points; count++){
    r = r + sqrt(pow(x_prime[count]-h,2) + pow(y_prime[count]-k,2));
    }
    r = r / points;
    
    printf("Best-fit circle center is: %f, %f\nBest-fit circle radius is: %f\n", h, k, r);
    }

    I have not a clue what the problem is.

  2. #2
    cas
    cas is offline
    Registered User
    Join Date
    Sep 2007
    Posts
    979
    The problem is this:
    Code:
    (1 / 2)(sigma[2] + sigma[3])
    You have to use * to multiply in C, if that's what you're trying to do. The compiler sees the opening parenthesis and thinks you're calling a function.

    Incidentally, 1/2 is always zero in C, because 1 and 2 are integers and integer division truncates. You could try 1.0/2 to get a double, or of course just 0.5.

  3. #3
    Registered User
    Join Date
    Aug 2008
    Posts
    15
    Thanks, man. I knew it had to be something really stupid like that.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Passing A Function From One Object to Another
    By HalNineThousand in forum C++ Programming
    Replies: 8
    Last Post: 03-28-2008, 07:26 PM
  2. dllimport function not allowed
    By steve1_rm in forum C++ Programming
    Replies: 5
    Last Post: 03-11-2008, 03:33 AM
  3. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 04:45 PM
  4. Function doesn't return an object
    By Aiwendil in forum C++ Programming
    Replies: 2
    Last Post: 04-10-2004, 03:15 PM
  5. qt help
    By Unregistered in forum Linux Programming
    Replies: 1
    Last Post: 04-20-2002, 09:51 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21