Thread: floating point values

  1. #1
    Registered User
    Join Date
    Dec 2005

    floating point values

    i am trying to do the following:

    program that reads two floating-point values representing angles and displays a message stating which angle has the greater tangent value. Note that the trigonometric functions in the math library expect angles in radians, not degrees. 360 degrees = 2 x pi radians, so 45 degrees would be about 0.785 radians.

    I have come up with code that takes in 2 numbers and displays the highest values. What I am stuck on is the calculations part. I am searching online and reading the books. Any help in this area will be great. Here is the code I have so far:

    #include <iostream>
    using std::cout;
    using std::cin;
    using std::endl;
    int main()
    float x,y;
    cout<< "Enter the first angle: ";
    cin>> x;
    cout<< "Enter the second angle: ";
    cin>> y;
    if ( x > y )
    cout << " The highest angle is "<< x <<endl;
    cout<< "The highest angle is "<< y <<endl;

  2. #2
    ^ Read Backwards^
    Join Date
    Sep 2005
    (acos(-1) * user_input) /180;
    Converts it to radians.

    acos(-1) = arccos(-1) = Pi

    Though, in your code you use no trig functions so why does it matter.
    Also though, just because a number is negative does not mean it is a smaller angle, but the < > will take negative numbers as smaller.
    Last edited by Enahs; 12-14-2005 at 09:32 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How accurate is the following...
    By emeyer in forum C Programming
    Replies: 22
    Last Post: 12-07-2005, 11:07 AM
  2. checking for floating point number
    By ssharish2005 in forum C Programming
    Replies: 6
    Last Post: 10-18-2005, 08:14 PM
  3. floating point question
    By Eric Cheong in forum C Programming
    Replies: 8
    Last Post: 09-10-2004, 10:48 PM
  4. Floating point numbers in a binary file
    By frenchfry164 in forum C++ Programming
    Replies: 6
    Last Post: 07-31-2003, 10:04 AM
  5. Replies: 2
    Last Post: 09-10-2001, 12:00 PM