int scores[] = { 90, 85, 95, 87, 92 }; int count = sizeof(scores) / sizeof(scores[0]); // using C-style counting
std::arrayThis example shows how to get the count of elements in an array using the std::array class, which has a built-in size() method. Package library: Standard Template Library (STL)numbers = { 1, 2, 3, 4, 5 }; int count = numbers.size(); // using std::array class