low value, high value and increment

This is a discussion on low value, high value and increment within the C Programming forums, part of the General Programming Boards category; Hello CProgrammers, Future programmer need help with a code. I am to design a program that reads a low value, ...

  1. #1
    Unregistered
    Guest

    low value, high value and increment

    Hello CProgrammers,

    Future programmer need help with a code. I am to design a program that reads a low value, a high value and 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 of low and high at increments of increment.

    If the value of low, high and increment are 1, 1.55 and 0.1 the table should look like:

    Value Square Root Cubic Root
    1.0 1.0 1.0
    1.1 1.04881 1.03228

    and so on....
    Here is the code that I have done and I am having problems working pass this point, any help will be greatly appreciated!
    CODE : (oh, how do you all put the code in small print so it could be easily understood..)


    # 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=0.1;
    do}
    low value=low value+increment;
    printf("%1f", low_value);
    printf(" %f", sqrt(low_value));

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,558
    First off, you get a compiler, and you figure out how to use it

    > int main(void) }
    I mean, what is this all about?

    > double sqrt(double x);
    > double pow (double x, double y);
    These are already in math.h, you don't need to say it twice

    Then you start here
    Code:
    #include <stdio.h> 
    #include <math.h> 
    
    int main(void) {
        /*variable declarations*/ 
        double low_value,high_value,increment; 
    
        printf("ENTER LOW VALUE: "); 
        scanf("%lf", &low_value);
        printf( "You entered %f\n", low_value );
    
        return 0;
    }
    Having got this working, you add your code a few lines at a time (say 5 max), and you make sure it COMPILES AND WORKS before rushing into the rest of the program.

    Writing a whole mess of code, and hoping it will all work (or you'll get someone on a message board to fix it) isn't going to happen.

    For what it's worth - you've got most of the bits - it just needs sorting out so it will compile.

    > (oh, how do you all put the code in small print so it could be easily understood..)
    You read this link
    vB Code [help]
    http://www.cprogramming.com/cboard/m...bbcode#buttons

  3. #3
    Unregistered
    Guest

    Wink

    Wow Salem! you do know how to show TOUGH LUV Thanks!
    I will go to my room and work on this code and thanks for the link.

Popular pages Recent additions subscribe to a feed

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