Thread: Need Help with program!

  1. #1
    Registered User
    Join Date
    Oct 2001

    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:" );
    printf("ENTER HIGH VALUE:" );
    printf("----- ----------- ----------\n");
    printf("%f", low_value);
    printf(" %f", sqrt(low_value));
    printf(" %f\n", pow(low_value,.33333));
    printf("%1f", low_value);
    printf(" %f", sqrt(low_value));
    printf(" %f\n", pow(low_value, .33333));
    return 0;

  2. #2
    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

    Get off my Intarweb!!!!

  3. #3
    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
    Good for you! Feel free to pat yourself on the back at any time

    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, 01: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, 01:41 PM
  3. Replies: 4
    Last Post: 02-21-2008, 10:39 AM
  4. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM