Results 1 to 5 of 5

Thread: What is the sqrt() : C++

  1. #1
    Join Date
    Dec 2009
    Posts
    26

    What is the sqrt() : C++

    I am working in the XYZ company as software developer. We can use the C++ language for developing the software. Hence, I can not know about the sqrt() function of the C++ language. So, I would like to know about the sqrt() function of the C++ language. I also would like to know about what is the use of the sqrt() function of the C++ language. Can anyone has the solution for me then reply!!!!

  2. #2
    Join Date
    May 2008
    Posts
    2,012

    The sqrt() function : C++

    The sqrt() function of the C++ language can be used to calculate the square root of an elements of the valarray. The sqrt() function can returns an object of the valarray that can be consisting of the square root of all an elements of z. The sqrt() function can overloads the cmath's sqrt function. The sqrt() function can be a member function of the valarray.

  3. #3
    Join Date
    Apr 2008
    Posts
    2,005

    The sqrt() : C++

    The following program could states you that how you can use the sort() function in the C++ language programming while using the sort() function in the programming as shown below :
    Code:
    #include <valarray>
    #include <iostream>
    #include <cmath>
    int main( )
    {
       using namespace std;
       int g;
       valarray<double> w1 ( 6 );
       for ( g = 0 ; g < 5 ; g++ )
          w1 [ g ] = g * g;
       cout << "The initial valarray is: ( ";
          for ( g = 0 ; g < 5 ; g++ )
             cout << w1 [ g ] << " ";
       cout << ")." << endl;
       valarray<double> w2 = sqrt ( w1 );
       cout << "The square root of the initial valarray is: ( ";
          for ( g = 0 ; g < 5 ; g++ )
             cout << w2 [ g ] << " ";
       cout << ")." << endl;
    }
    Output
    Code:
    The initial valarray is: ( 0 1 4 9 16 ).
    The square root of the initial valarray is: ( 0 1 2 3 4 ).

  4. #4
    Join Date
    May 2008
    Posts
    2,297

    What is the sqrt() : C++

    The sqrt() function can computes the square root of an elements of the valarray. The sqrt() function can displays an object of the valarray that can be containing the square root of all the elements of c. The sqrt() function can overloads the cmath's sqrt function. The following can be the general form of the sqrt() function of the C++ :
    Code:
    template<class W> valarray<W> sqrt (const valarray<W>& c);

  5. #5
    Join Date
    Nov 2005
    Posts
    1,323

    Re: What is the sqrt() : C++

    The following can be the parameter of the sqrt() function of the C++ language :
    1. c : This parameter of the sqrt() function of the C++ language can contains valarray consisting of an elements of a type for that the unary function sqrt can be defined. The sqrt () function can returns the value of a valarray object along with the square roots of an elements of c. For example :
    Code:
    #include <cmath>
    #include <iostream>
    using namespace std;
    int main()
    {
        for(int y = 1; y < 11; y++)
        {
            cout<<"Square root of: "<<y<<" is "<<sqrt(y)<<endl;
        }
    }
    The above an example can produce the sqare root of given numbers that is 1 to 10.

Similar Threads

  1. C : Implementation of sin(),pow(),sqrt()
    By Adolfa in forum Software Development
    Replies: 4
    Last Post: 30-01-2010, 12:41 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,714,024,814.44869 seconds with 17 queries