Need Help with program!

This is a discussion on Need Help with program! within the C Programming forums, part of the General Programming Boards category; Hello, this program is to read a low value, a high value an increment value ensure that the low value ...

  1. #1
    Registered User
    Join Date
    Oct 2001
    Posts
    24

    Need Help with program!

    Hello, this program is to read a low value, a high value an increment value ensure that the low value is less than or equal to the high value and computes and prints a table of square roots, and cubic roots for all values from low to high at increments of increment. Thanks for the help!


    # include <stdio.h>
    # include <math.h>
    double sqrt(double x);
    double pow (double x, double y);
    int main(void) {

    /*variable declarations*/
    double low_value,high_value,increment;

    printf("ENTER LOW VALUE: ");
    scanf("%1f", &low_value);
    printf("ENTER HIGH VALUE: ");
    scanf("%1f", &high_value);
    while (high_value <= low_value)
    {
    printf("*****RE ENTER VALUES*****\n");
    printf("ENTER LOW VALUE:" );
    scanf("%1f",&low_value);
    printf("ENTER HIGH VALUE:" );
    scanf("%1f",&high_value);
    }
    {
    printf("\n");
    printf("VALUE SQUARE ROOT CUBIC ROOT\n");
    printf("----- ----------- ----------\n");
    printf("%f", low_value);
    printf(" %f", sqrt(low_value));
    printf(" %f\n", pow(low_value,.33333));
    increment=1,
    do
    }
    low_value=low_value+increment;
    printf("%1f", low_value);
    printf(" %f", sqrt(low_value));
    printf(" %f\n", pow(low_value, .33333));
    }
    return 0;

  2. #2
    Nosepicker DrakkenKorin's Avatar
    Join Date
    Nov 2001
    Posts
    407
    Ok, help me out here. I'm not entirely sure I'm understanding your code.

    You have:
    some includes
    some prototypes
    and your main.
    Then your variables
    and a while. ::all fine and good, I follow it up to here::

    ::Here's where I lose you::
    you open up a {
    have some code and a do with }{
    then your retrun 0.

    Why do you open up a new { inside the main if its not another function or test? And is that do supposed to be a do while? And why ask for a high value if you never use it in any of your computations or use it in any test except to make sure that the high value is actually higher than the low value?

    This just came to me: why have a sqrt(double x) and pow(double x, double y) functions when math.h already does these for you, you don't need them as functions. At least I don't think you do.

    A lot of unbalanced {}'s
    DrakkenKorin

    Get off my Intarweb!!!!

  3. #3
    Unregistered
    Guest
    DrakkenKorin
    Hi, thanks for your help, I did more reading and applying myself and now I have the program running error free, again thanks for your help!

  4. #4
    Nosepicker DrakkenKorin's Avatar
    Join Date
    Nov 2001
    Posts
    407
    Good for you! Feel free to pat yourself on the back at any time
    DrakkenKorin

    Get off my Intarweb!!!!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Issue with program that's calling a function and has a loop
    By tigerfansince84 in forum C++ Programming
    Replies: 9
    Last Post: 11-12-2008, 12:38 PM
  2. Need help with a program, theres something in it for you
    By engstudent363 in forum C Programming
    Replies: 1
    Last Post: 02-29-2008, 12:41 PM
  3. Replies: 4
    Last Post: 02-21-2008, 09:39 AM
  4. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM

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