iterate over a range in c++
#include <iostream>
int main() {
// Define a range using iterators
int arr[] = {1, 2, 3, 4, 5};
int* begin = std::begin(arr);
int* end = std::end(arr);
// Iterate over the range using a for loop
for (int* it = begin; it != end; ++it) {
// Access the current element using the iterator
int value = *it;
// Print the current element
std::cout << value << " ";
}
// Output: 1 2 3 4 5
return 0;
}