valarray end() function in C++ Last Updated : 24 Oct, 2018 Comments Improve Suggest changes Like Article Like Report 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 object. Returns: This function returns the iterator to the past-the-end in the valarray. Below programs illustrate the above function: Example 1:- CPP // C++ program to demonstrate // example of end() 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 end() 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 info B bansal_rtk_ Follow Improve Article Tags : Misc C++ CPP-Functions cpp-valarray Explore C++ BasicsIntroduction to C++ Programming Language3 min readData Types in C++7 min readVariables in C++4 min readOperators in C++9 min readBasic Input / Output in C++5 min readControl flow statements in Programming15+ min readLoops in C++7 min readFunctions in C++8 min readArrays in C++8 min readCore ConceptsPointers and References in C++5 min readnew and delete Operators in C++ For Dynamic Memory5 min readTemplates in C++8 min readStructures, Unions and Enumerations in C++3 min readException Handling in C++11 min readFile Handling through C++ Classes8 min readMultithreading in C++8 min readNamespace in C++5 min readOOP in C++Object Oriented Programming in C++8 min readInheritance in C++10 min readPolymorphism in C++5 min readEncapsulation in C++4 min readAbstraction in C++4 min readStandard Template Library(STL)Standard Template Library (STL) in C++3 min readContainers in C++ STL3 min readIterators in C++ STL10 min readC++ STL Algorithm Library2 min readPractice & ProblemsC++ Interview Questions and Answers1 min readC++ Programming Examples7 min read Like