Thread: Exponent and C4550

  1. #1
    Registered User
    Join Date
    Dec 2013
    Posts
    5

    Exponent and C4550

    Hey guys. I am new to C programming and I am trying to compile and run an exponent program my instructor posted for us but it is giving me an error saying:

    Warning c4550: expression evaluates to a function which is missing an argument list.

    My instructor is not really helpful with why this is happening (she doesn't seem to find anything wrong with the code). From what I could gather there is some issue with the math but idk. It is supposed to prompt for the number and the exponent to raise it to, then calculate and output the result.

    Code:
    #include <stdio.h>
    int main()
    {
    int base, exp;
    long long int value=1;
    printf("Enter the base number and exponent: ");
    scanf("%d%d", &base, &exp);
    while (exp!=0);
    {
    value*=base;   /* value = value*base; */
    --exp;
    }
    printf;
    }

  2. #2
    Registered User
    Join Date
    Oct 2012
    Posts
    126
    change the name of exp, also your printf statement should be

    printf("%d", value);

  3. #3
    Registered User
    Join Date
    Dec 2013
    Posts
    5
    Alright. It runs now but I have tried all different ways of entering the two numbers but the program never actually does the math.

    Code:
    #include <stdio.h>
    int main()
    {
    int base, power;
    long long int value=1;
    printf("Enter the base number and exponent: ");
    scanf("%d%d", &base, &power);
    while (power!=0);
    {
    value*=base;   /* value = value*base; */
    --power;
    }
    printf("%d", value);
    }

  4. #4
    Registered User
    Join Date
    Oct 2012
    Posts
    126
    you have a semi colon after your while loop, while loop never executes

    while(power!=0) then you have this semicolon, can't do that, delete it and you're good
    Last edited by Sorinx; 12-16-2013 at 12:09 AM.

  5. #5
    Registered User
    Join Date
    Dec 2013
    Posts
    5
    Exponent and C4550-exponent-png

    I changed it and it still isn't working :/ I tried 2 space 2; 2 enter 2; 2 comma 2; 2 semicolon 2

    Nothing works.

  6. #6
    Registered User
    Join Date
    Oct 2012
    Posts
    126
    Code:
    #include <stdio.h>
    int main()
    {
    int base, cat;
    long int value=1;
    printf("Enter the base number and exponent: ");
    scanf("%d", &base);
    scanf("%d", &cat);
    while (cat!=0)
    {
    value*=base;   /* value = value*base; */
    cat--;
    }
    printf("%d", value);
    }
    use your scanf in two different lines

  7. #7
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    > scanf("%d%d", &base, &power);
    You need to separate your input with spaces, not commas.

    If you want a comma separator on input, then your format string needs to contain a comma.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  8. #8
    Registered User
    Join Date
    Dec 2013
    Posts
    5
    Exponent and C4550-exponent-png

    I changed it and it still isn't working :/ I tried 2 space 2; 2 enter 2; 2 comma 2; 2 semicolon 2

    Nothing works.

  9. #9
    Registered User
    Join Date
    Oct 2012
    Posts
    126
    I know for a fact it works, my semicolon comments were from your actual code, you would have to enter it in as 2 2 from what you typed as Salem said. You need to just break them into two different scanf, honestly scanf isn't a good function to use for many reasons. Just do as I showed you

  10. #10
    Registered User
    Join Date
    Dec 2013
    Posts
    5
    Ahhhh I actually didn't see your last two posts until just now I checked it and what you posted works great. It makes a lot of sense to put the scanf on separate lines actually. Thank you for the help!!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Using an Exponent in C++
    By NismoT in forum C++ Programming
    Replies: 7
    Last Post: 09-26-2011, 09:11 AM
  2. Does anyone know how to do exponent with just addition?
    By cowboyz209 in forum C Programming
    Replies: 11
    Last Post: 05-03-2011, 02:26 PM
  3. Some Exponent Help
    By jrahhali in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 06-04-2005, 07:31 PM
  4. Exponent help
    By flatline911 in forum C++ Programming
    Replies: 4
    Last Post: 08-15-2003, 01:34 AM
  5. exponent
    By tmoney$ in forum C Programming
    Replies: 2
    Last Post: 04-14-2003, 02:24 PM

Tags for this Thread