How do i write this program?

hey, I am a college stundent who was assigned to write a simple beginners C++ program and i needed some help. I am just starting out in the language and I didn't get a chance to go through the assigned readings, For Anyone who is bored, I would really appreciate if you folks wrote this program, Thanks.

here is the link of my assignment:

http://s273.photobucket.com/albums/jj230/euser985/?action=view&current=untitled.jpg
it looks like you're learning the functions found in the cmath library. so, your program's going to look something along the lines of

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
include <math.h>
include <iostream.h>

int main() {
     double num, den, y;

     for (double x = -4.0; x <= 3.0; x += 0.5) {
          // Calculate the numerator, storing it in num. You'll need to make calls to the
          // function pow(), that's found in the cmath library. An example can be found
          // here: http://www.cplusplus.com/reference/clibrary/cmath/pow.html

          // Calculate the denomenator, storing it in den. You'll need to make calls to
          // the functions fabs() and sqrt(), both are found in the cmath library.
          // Examples can be found here:
          // http://www.cplusplus.com/reference/clibrary/cmath/fabs.html
          // http://www.cplusplus.com/reference/clibrary/cmath/sqrt.html

          // The technical aspects of the assignment go something like this.
          y = num/den;
          cout << "X=" << x << " Y=" << y << endl;
          cout << "Y IS ";
          if (y == 0)
               cout << "ZERO\n";
          else if (y < 0)
               cout << "NEGATIVE\n";
          else
               cout << "POSITIVE\n";
     } // End for on x.

     return 0;
}
Last edited on
Topic archived. No new replies allowed.