Create a program that evaluate an equation?

This is a discussion on Create a program that evaluate an equation? within the C Programming forums, part of the General Programming Boards category; Hi! I just started to learn C program and I ran into this little problem. This is the assignment: Write ...

  1. #1
    Registered User
    Join Date
    Oct 2011
    Posts
    1

    Create a program that evaluate an equation?

    Hi! I just started to learn C program and I ran into this little problem.

    This is the assignment:

    Write the C program that evaluates the value of y=pow(c,1+x), for x in the
    interval: a<x<=b. Scan double values of a and b>a. Scan a double value c>0.
    Then, scan x and evaluate y and y/x. If x is not from the required interval a<x<=b,
    scan it again, shown in the output below. If you don't scan it correctly twice in a row,
    exit the program (as shown in the output below). To exit, use the function exit(0), but
    don't forget to include stdlib.h above the main.

    Your output should look like:

    Code:
    Enter a and b>a:
    0.5 2.75
    Enter c>0:
    1.5
    enter a double a<x<=b:
    0.25
    The x value is = 0.250000
    You didn't enter x from a<x<=b!
    Enter x from a<x<=b:
    2.5
    The y value is = 4.133514
    The y/x value is = 1.653406
    ......

    On the other hand, if you don't enter proper x twice in a row, you output
    should look like:
    Code:
    Enter a and b>a:
    0.5 2.75
    Enter c>0:
    1.5
    enter a double a<x<=b:
    0.25
    The x value is = 0.250000
    You didn't enter x from a<x<=b!
    Enter x from a<x<=b:
    3.1
    You didn't enter x from a<x<=b! Exit!
    ----------------------------------------------------

    This is what I attempted so far:
    Code:
    #include <stdio.h>
    #include <stdlib.h>
    int main(void)
    {
            int num1, num2, num3, num4;
    
            printf("Enter a and b>a:");
            scanf("%lf %lf",num1, num2);
            printf("Enter c>0:");
            scanf("%lf",num3);
            printf("Enter a double a<x<=b:");
            scanf("%lf",num4);
            return 0;
    }
    I am kind of lost right now. Could you guys give out some adivice or hints how to do this. Thank you!

  2. #2
    Registered User
    Join Date
    May 2011
    Location
    Around 8.3 light-minutes from the Sun
    Posts
    1,866
    Sure, my advice is that you missed some classes and you shouldn't do that. I suggest you review your book on loops, and maybe learn something about the math lib. For loops look at:Lesson 3: Loops in the board's C Made Easy Series. As for the math lib, I think you can find that all by yourself.
    Quote Originally Posted by anduril462 View Post
    Now, please, for the love of all things good and holy, think about what you're doing! Don't just run around willy-nilly, coding like a drunk two-year-old....
    Quote Originally Posted by quzah View Post
    ..... Just don't be surprised when I say you aren't using standard C anymore, and as such,are off in your own little universe that I will completely disregard.
    Warning: Some or all of my posted code may be non-standard and as such should not be used and in no case looked at.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 8
    Last Post: 02-08-2011, 03:23 AM
  2. C++ Program to evaluate expressions
    By DMEngOba in forum C++ Programming
    Replies: 5
    Last Post: 05-25-2009, 10:16 PM
  3. Math Equation Program (I can't find the problem with my program!)
    By masked_blueberr in forum C Programming
    Replies: 14
    Last Post: 07-06-2005, 12:53 PM
  4. Help! Program to evaluate expression...
    By Unregistered in forum C++ Programming
    Replies: 7
    Last Post: 02-19-2002, 06:20 AM
  5. Evaluate postfix expression program
    By shad0w in forum C Programming
    Replies: 1
    Last Post: 12-23-2001, 04:40 PM

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