Thread: Fourth root program. Help plese?

  1. #1
    TransparentMember correlcj's Avatar
    Join Date
    Jun 2002
    Posts
    378

    Question Fourth root program. Help plese?

    Hello,
    i am to write a table of square roots and forthr roots like see:

    Integer Square root forth root

    1 1.00000000 1.00000000
    2 1.414213562 1.189207115
    3 1.732050808 1.1316074013
    4 2.000000000 1.414213562

    Now! I am good so far with the square root but my forth root is not coming out right. It reads 2.65 something or another and i need some help please.


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

    void prn_heading (void);
    void prn_and_read_data (void);

    int main()
    {
    prn_heading();
    prn_and_read_data();
    return 0;
    }

    void prn_heading(void)
    {
    printf("%3s%28s%28s%28s",
    "Integer", "Square Root", "Fourth Root\n",
    "--------------------------------------------------------------\n\n");
    return;
    }

    void prn_and_read_data (void)
    {
    int x;
    double square_root, fourth_root;

    for (x = 1; x <= 100; ++x)
    printf("%5d:%28.9e %28.9e\n", x = x, sqrt(x), square_root = pow(x, x));
    fourth_root = square_root * square_root;
    printf("%50.9e", fourth_root);
    ;
    return;
    }
    "Be formless, shapeless, like water... You put water into a cup, it becomes the cup, you put water into a bottle, it becomes the bottle, you put it in a teapot, it becomes the teapot... Now water can flow, or it can crash, be water my friend."
    -Bruce Lee

  2. #2
    Registered User Draco's Avatar
    Join Date
    Apr 2002
    Posts
    463
    hm.....try using the pow() function for the fourth root. I'm not familiar with the function, but maybe that would work better. Why did you double-post instead of continuing on the last one? Most people don't like it when you do that.

  3. #3
    TransparentMember correlcj's Avatar
    Join Date
    Jun 2002
    Posts
    378

    Talking Ooopss!

    I forgot!
    I have alot of message boards i run and too many to keep track of whats going in and out. I am sure they'll send me a law suit sometime in the mail or they can just take a deep breath and relax. They can chaulk it up one for the home team, huh?
    later
    "Be formless, shapeless, like water... You put water into a cup, it becomes the cup, you put water into a bottle, it becomes the bottle, you put it in a teapot, it becomes the teapot... Now water can flow, or it can crash, be water my friend."
    -Bruce Lee

  4. #4

  5. #5
    TransparentMember correlcj's Avatar
    Join Date
    Jun 2002
    Posts
    378

    Cool forget that!?!?

    I am a rebel! A rebel without a cause! A rebel with no boundries to where he or she may be going!
    Or i can just say i forgot and if they dont like OH Darn.
    "Be formless, shapeless, like water... You put water into a cup, it becomes the cup, you put water into a bottle, it becomes the bottle, you put it in a teapot, it becomes the teapot... Now water can flow, or it can crash, be water my friend."
    -Bruce Lee

  6. #6
    Registered User
    Join Date
    Jan 2002
    Posts
    552
    thats probably the closest your gonna get using the standard library functions, i dont know of any power function that will take double for an exponent

  7. #7
    TransparentMember correlcj's Avatar
    Join Date
    Jun 2002
    Posts
    378

    Mr clown pimp, pimp, dog, sir

    Hello,
    Thanks for your help Mr. Clown Pimp!
    Is there anyway to write it though to produce the same results... say using exponents
    eg; say prints for int 2, 1.414213562e+00
    I am curious since this program has really gotten me stumped here but thanks for your gracious knowledge.
    later big pimppy!

    "Be formless, shapeless, like water... You put water into a cup, it becomes the cup, you put water into a bottle, it becomes the bottle, you put it in a teapot, it becomes the teapot... Now water can flow, or it can crash, be water my friend."
    -Bruce Lee

  8. #8
    Registered User Draco's Avatar
    Join Date
    Apr 2002
    Posts
    463
    not to get off topic, but what does the pow() function do?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. need help program crashing
    By tunerfreak in forum C++ Programming
    Replies: 14
    Last Post: 05-22-2006, 11:29 AM
  2. Need help with my program...
    By Noah in forum C Programming
    Replies: 2
    Last Post: 03-11-2006, 07:49 PM
  3. Linked List program need help
    By ykchua in forum C Programming
    Replies: 3
    Last Post: 08-05-2004, 10:18 AM
  4. never compile as root!
    By Lynux-Penguin in forum Linux Programming
    Replies: 6
    Last Post: 08-21-2003, 05:46 PM
  5. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM