← Back to Question List
C++ Code Walkthrough #2
Pointer Arithmetic
📄 Code
Read carefully — what does this print?1#include <iostream>2using namespace std;34int main() {5 int arr[] = {10, 20, 30, 40, 50};6 int *ptr = arr;7 cout << *ptr << endl;8 ptr += 2;9 cout << *ptr << endl;10 cout << *(ptr + 1) << endl;11 return 0;12}