Results 1 to 6 of 6

Thread: Use of the tan() function : C++

  1. #1
    Join Date
    Dec 2009
    Posts
    28

    Use of the tan() function : C++

    I am the student of the MSC-IT. I could had the well knowledge of the C++ programming language. But I can not know much more about the built-in functions of C++ programming language. So, I want to know about the tan() function of the C++ language. I also want to know about how can I use the tan() function in the C++ programming language. Thus, Can anyone has the proper answer on the tan() function in the C++ language. Reply Me!!!

  2. #2
    Join Date
    Oct 2005
    Posts
    2,393

    The tan() function : C++

    The tan() function of the C++ language can calculates the tangent of an elements of the valarray. The tan() function can returns an object of the valarray that can be consisting of the tangents of all an elements of y. The following can be the syntax of the tan() function of the C++ language as follows :
    Code:
    template<class W> valarray<W> tan (const valarray<W>& y);

  3. #3
    Join Date
    May 2008
    Posts
    2,389

    Use of the tan() function : C++

    A valarray whose elements can be equal to the tangen elements of the input valarray. The following can be the parameters of the tan() function in the C++ programming language :
    1. y : This parameter of the tan() function can be used to contains a valarray that can be consisting of an elements of a type for that the unary function tan can be defined. Every an element's value can represents an angle that can be an expressed in radians.

  4. #4
    Join Date
    Feb 2008
    Posts
    1,852

    Re: Use of the tan() function : C++

    The following program could states you that how you can use the tan() function in the C++ language coding while using the tan() function in the coding as shown :
    Code:
    using namespace std;
    #include <cmath>
    #include <valarray>
    #include <iostream>
    int main ()
    {
      double wl[] = {0.35, 1.22, 3.4};
      wlarray<double> e (wl,3);
      wlarray<double> br = tan (e);
      cout << "e: ";
      eor (size_t k=0; k<e.size(); ++k)
    	  cout << e[k] << ' ';
      cout << endl;
      cout << "br: ";
      eor (size_t k=0; k<br.size(); ++k)
    	  cout << br[k] << ' ';
      cout << endl;
      return 0;
    }
    Output:
    Code:
    e: 0.35 1.22 3.4
    br: 0.335376 0.839654 0.997775

  5. #5
    Join Date
    Jan 2008
    Posts
    1,521

    Re: Use of the tan() function : C++

    The tan() function can returns the tangent of an argument ag, where an ag can be given in radians. If ag can be an infinite then tan() function can returns NAN and can raise a floating-point an exception. C++ can also provides the following overloaded forms as :
    Code:
     #include <cmath>
        float tan( float ag ); 
        long double tan( long double ag );

  6. #6
    Join Date
    Apr 2008
    Posts
    1,948

    tan() function : C++

    I can suggest you that to carefully go through the following code of lines that can demonstrates you how to use the tan() function in the C++ programming as follows :
    Code:
    #include <valarray>
    #include <iostream>
    #include <iomanip>
    int main( )
    {
       using namespace std;
       double pi = 3.14159265359;
       int j;
       valarray<double> wa1 ( 9 );
       for ( j = 0 ; j < 9 ; j++ ) 
          wa1 [ j ] =  ( pi/2 ) * ( 0.25 * j - 1 );
       valarray<double> wa2 ( 9 );
       cout << "The initial valarray is:\n";
       for ( j = 0 ; j < 9 ; j++ )
          cout << setw( 10 ) << wa1 [ j ]
          << "     radians, which is   "
          << setw( 5 ) << ( 180/pi ) * wa1 [ j ]
          << "   degrees" << endl;
       cout << endl;
       wa2 = tan ( wa1 );
       cout << "The tangent of the initial valarray is:\n ";
       for ( j = 0 ; j < 9 ; j++ )
          cout << wa2 [ j ] << endl;
    }
    Output
    Code:
    The initial valarray is:
       -1.5708     radians, which is     -90   degrees
       -1.1781     radians, which is   -67.5   degrees
     -0.785398     radians, which is     -45   degrees
     -0.392699     radians, which is   -22.5   degrees
             0     radians, which is       0   degrees
      0.392699     radians, which is    22.5   degrees
      0.785398     radians, which is      45   degrees
        1.1781     radians, which is    67.5   degrees
        1.5708     radians, which is      90   degrees
    
    The tangent of the initial valarray is:
     9.6701e+012
    -2.41421
    -1
    -0.414214
    0
    0.414214
    1
    2.41421
    -9.6701e+012

Similar Threads

  1. c++ equivalent function to the c-function 'sprintf
    By Dilbert in forum Software Development
    Replies: 6
    Last Post: 13-12-2011, 04:03 PM
  2. c# function equivalent to gettime function in javascript
    By Omaar in forum Software Development
    Replies: 4
    Last Post: 10-03-2010, 10:44 PM
  3. Replies: 5
    Last Post: 27-02-2010, 07:52 PM
  4. How does abstract function differs from virtual function?
    By Maddox G in forum Software Development
    Replies: 5
    Last Post: 29-01-2010, 11:32 AM
  5. Function keys don't function under windows XP
    By GunFighter in forum Hardware Peripherals
    Replies: 3
    Last Post: 08-04-2009, 11:07 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,751,772,275.58780 seconds with 16 queries