#include#include #include using namespace std; int main() { vector nums = {10, 20, 30, 40, 50}; vector ::iterator it; for (it = nums.begin(); it != nums.end(); ++it) { cout << *it << " "; } return 0; }
#includeIn this code, we have created an integer array "nums" containing five integers. We have then created a pointer "ptr" and initialized it to the beginning of the array using "nums". In the for loop, we print each element of the array using the pointer and increment the pointer until it reaches the end of the array. The "iterator" module is part of the C++ standard library.#include using namespace std; int main() { int nums[] = {10, 20, 30, 40, 50}; int* ptr; for (ptr = nums; ptr < nums + 5; ++ptr) { cout << *ptr << " "; } return 0; }