Namespaces
Variants
Actions

std::valarray<T>::size

From cppreference.com
< cpp‎ | numeric‎ | valarray
 
C++
 
Numerics library
 
std::valarray
std::size_t size() const;

Returns the number of elements in the valarray.

Contents

[edit] Parameters

(none)

[edit] Return value

Number of elements in the valarray.

[edit] Example

#include <iostream>
#include <valarray>
 
int main()
{
    std::valarray<double> a = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
    std::cout << "Average: " << a.sum()/a.size() << '\n';
}

Output:

Average: 5.5

[edit] See also

changes the size of valarray
(public member function) [edit]

Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!

Check out: eBank.nz (Art Generator) | Netwrck.com (AI Tools) | Text-Generator.io (AI API) | BitBank.nz (Crypto AI) | ReadingTime (Kids Reading) | RewordGame | BigMultiplayerChess | WebFiddle | How.nz | Helix AI Assistant