Thread: double pow not working?

  1. #1
    Registered User
    Join Date
    Apr 2006
    Posts
    24

    double pow not working?

    Code:
    printf("Approximate cos(%d) = %lf", xdeg, 1-(double pow(radians, 2)/2) + (double pow(radians, 4)/24);
    This is just a part of it, but everything seems to be right except for an error I get.

    Code:
    test.c:32: error: parse error before "pow"
    test.c:32: error: parse error before ';' token
    Anyone know if this is a very simple mistake or is something wrong with my whole program?

  2. #2
    Registered User joed's Avatar
    Join Date
    Mar 2004
    Posts
    59
    Double is the return type, you don't need it in the program. Just do pow(a, b).

  3. #3
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    You aren't supposed to specify a return value when you make a function call. C finds the correct function to use by name and parameter list.
    PHP Code:
    printf("Approximate cos(%d) = %lf"xdeg1pow(radians2)/pow(radians4)/24); 
    That will run fine.

    The exception here is when you want to typecast the return value, where you would have syntax issues:
    PHP Code:
     printf("Approximate cos(%d) = %lf"xdeg1- (double) pow(radians2)/+  (double) pow(radians4)/24); 
    This runs fine too, but you should only do this when the function the compiler will call will not return the necessary return type.
    Last edited by whiteflags; 05-01-2006 at 05:40 PM.

  4. #4
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    Your second error was due to a missing ')'.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Structures within structures for a database
    By Holtzy in forum C Programming
    Replies: 2
    Last Post: 04-30-2008, 07:06 AM
  2. Help with multi function progam
    By WackoWolf in forum C Programming
    Replies: 22
    Last Post: 10-13-2005, 02:56 AM
  3. Please HELP!!
    By traz in forum C++ Programming
    Replies: 4
    Last Post: 04-14-2003, 09:20 PM
  4. what's the difference?
    By iluvmyafboys in forum C++ Programming
    Replies: 13
    Last Post: 02-28-2002, 09:25 PM
  5. Hi, could someone help me with arrays?
    By goodn in forum C Programming
    Replies: 20
    Last Post: 10-18-2001, 09:48 AM