Thread: Getting Error: Called Object is not a Function

  1. #1
    Registered User
    Join Date
    Jun 2010

    Unhappy Getting Error: Called Object is not a Function

    Hello All,

    This is just a simple programming challenging from a book I'm using to learn C, it doesn't call for the if/else statement but I wanted to add it. I have used if/else before successfully, but for some reason now on the else portion it wont do the calculation. At first I thought celsius was a reserved word and thats why it was failing, but so I changed the variables name but still same error.

    #include <stdio.h>
        int Choice; /* stores users choice on conversion */
        double fahrenheit; /* stores the temp in Fahrenheit */
        double centigrade; /* stores the temp in Celsius */
        /* Asks the user what they want to convert. */
        printf("Please choose how you want to convert\n");
        printf("Press 1 for Celsius to Fahrenheit\n");
        printf("Press 2 for Fahrenheit to Celsius: ");
        scanf("%d", &Choice);
        /*Determines what the user chooses */
        if (Choice == 1)
            /* Obtains the temp and converts to fahrenheit */
            printf("\nPlease enter in the Temp in degree's Celsius: ");
            scanf("%lf", &centigrade);
            fahrenheit = (9/5 * centigrade)+32;
            printf("\n %.2f Celsius is %.2f Fahrenheit\n ", centigrade, fahrenheit);
            /* Obtains the temp and converts to Celsius */
            printf("\nPlease enter in the Temp in degree's Fahrenheit: ");
            scanf("%lf", &fahrenheit);
            centigrade = (5/9)(fahrenheit - 32);
            printf("\n %.2f Fahrenheit is %.2f Celsius\n", fahrenheit, centigrade);
    when compiled I get this error ConvertTemp.c:40: error: called object is not a function and line 40 is centigrade = (5/9)(fahrenheit -32); but the equation in the if statement runs fine, and if I take else out completely it runs fine. I read around about people with similar errors, and tried to use the fixes they had but most were when they were actually calling a function aside from stdio.h I'm not calling any others. Thanks in advance.

  2. #2
    Registered User
    Join Date
    May 2010
            centigrade = (5/9)(fahrenheit - 32);
    Simple, You forgot * multiplication operator!
    Wait, 5/9 will evaluate to zero! Use 5.0/9.0.
    Last edited by Bayint Naung; 06-22-2010 at 08:53 PM.

  3. #3
    Registered User
    Join Date
    Jun 2010
    Thanks so much, I was thinking that ()() would be multiplication like in algebra. I will make a note of that in the future, always have to use the operators.

  4. #4
    Join Date
    Oct 2007
    Inside my computer
    centigrade = (5.0/9)*(fahrenheit - 32);
    Works fine to. The standard specifies that when you perform arithmetic on two variables, they are converted to the same size first--the biggest size (and integers are promoted to floating point, too). Therefore, the result is a floating point temporary.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. Seg Fault in Compare Function
    By tytelizgal in forum C Programming
    Replies: 1
    Last Post: 10-25-2008, 03:06 PM
  3. Passing A Function From One Object to Another
    By HalNineThousand in forum C++ Programming
    Replies: 8
    Last Post: 03-28-2008, 07:26 PM
  4. dllimport function not allowed
    By steve1_rm in forum C++ Programming
    Replies: 5
    Last Post: 03-11-2008, 03:33 AM
  5. Function doesn't return an object
    By Aiwendil in forum C++ Programming
    Replies: 2
    Last Post: 04-10-2004, 03:15 PM