Thread: C programming help

  1. #1
    Registered User
    Join Date
    Oct 2010
    Posts
    3

    C programming help

    Hi all,
    i'm supposed to make a C program that takes a value 3 values from 3 different intervals and calculate for 'y'. this is what i have so far, but i can't get it to work right. any help please?


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

    main()
    {
    double x, y, A, B, C;
    int m, n, o;

    printf("Enter (double) A, B, C: ");
    scanf("%f %f %f", &A, &B, &C);

    do {
    n = 0;
    m = 0;
    o = 0;

    printf("Enter (double) x: ");
    scanf("%f", x);

    if (x <= 0 && m < 1)
    {
    y = A * pow(-x,1.5) - B + 10 * x;
    printf("x value is = %.4f and y value is = %.5f.", x, y);
    m++;
    }
    else if (x < 1 && x > 0 && n < 1)
    {
    y = A / x - B * pow(x,4) + pow(C,2);
    printf("x value is = %.4f and y value is = %.5f.", x, y);
    n++;
    }
    else if (x >= 1 && o < 1)
    {
    y = A * log(x) - B * x - C;
    printf("x value is = %.4f and y value is = %.5f.", x, y);
    o++;
    }
    else
    printf("Enter x from another interval!");

    } while (m < 1 && n < 1 && o < 1);

    getch(); return 0;

    }

    thanks!

  2. #2
    Registered User
    Join Date
    Oct 2010
    Posts
    107
    Welcome to the forum!

    I would be happy to help when I know what you need. Please
    1) Make threads with specific questions
    2) Use the code tags and indent your code
    3) Tell us in very specific terms what's wrong. (i.e my code won't compile and it gives error X, my code compiles but the scanf doesn't work, etc). Otherwise you're asking us to figure out what's wrong with your program for you.

Popular pages Recent additions subscribe to a feed