valarray begin() function in C++ Last Updated : 24 Oct, 2018 Summarize Comments Improve Suggest changes Share Like Article Like Report The begin() function is defined in valarray header file. This function returns an iterator pointing to the first element in the valarray v. Syntax: template< class T > begin( valarray<T>& v ); Parameter: This function takes a mandatory parameter v which represents the valarray object. Returns: This function returns the iterator to the first value in the valarray. Below programs illustrate the above function: Example 1:- CPP // C++ program to demonstrate // example of begin() function. #include <bits/stdc++.h> using namespace std; int main() { // Initializing valarray valarray<int> varr = { 10, 20, 30, 40, 50 }; cout << "valarray contains="; for (auto i = begin(varr); i != end(varr); i++) { cout << ' ' << *i; } cout << endl; return 0; } Output: valarray contains= 10 20 30 40 50 Example 2:- CPP // C++ program to demonstrate // example of begin() function. #include <bits/stdc++.h> using namespace std; int main() { // Initializing valarray valarray<int> varr = { -10, -20, -30, -40 }; cout << "valarray contains="; for (auto i = begin(varr); i != end(varr); i++) { cout << ' ' << *i; } cout << endl; return 0; } Output: valarray contains= -10 -20 -30 -40 Comment More infoAdvertise with us Next Article valarray apply() in C++ B bansal_rtk_ Follow Improve Article Tags : Misc C++ CPP-Functions cpp-valarray Practice Tags : CPPMisc Similar Reads valarray end() function in C++ The end() function is defined in valarray header file. This function returns an iterator pointing to the past-the-end element in the valarray v. Syntax: template< class T > end( valarray<T>& v ); Parameter: This function takes a mandatory parameter v which represents the valarray obj 1 min read valarray cos() function in C++ The cos() function is defined in valarray header file. This function is used to calculate cosine of the value of each element in valarray and returns a valarray containing the cosine of all the elements. Syntax: cos(varr); Time Complexity: O(1) Auxiliary Space: O(1) Parameter: This function takes a 2 min read multiset begin() and end() function in C++ STL The multiset::begin() is a built-in function in C++ STL that returns an iterator pointing to the first element in the multiset container. Since multiset always contains elements in an ordered way, begin() always points to the first element according to the sorting criterion. Syntax: iterator multise 2 min read valarray apply() in C++ The apply() function is defined in valarray header file. This function returns a valarray with each of its elements initialized to the result of applying func to its corresponding element in *this. Syntax: valarray apply (T func(T)) const; valarray apply (T func(const T&)) const; Parameter: This 2 min read valarray apply() in C++ The apply() function is defined in valarray header file. This function returns a valarray with each of its elements initialized to the result of applying func to its corresponding element in *this. Syntax: valarray apply (T func(T)) const; valarray apply (T func(const T&)) const; Parameter: This 2 min read std:: valarray class in C++ C++98 introduced a special container called valarray to hold and provide mathematical operations on arrays efficiently. It supports element-wise mathematical operations and various forms of generalized subscript operators, slicing and indirect access.As compare to vectors, valarrays are efficient in 5 min read Like