CJCoding With Joseph
15per day
← Back to Question List
C++ Code Walkthrough #2

Pointer Arithmetic

hardArrays

📄 Code

Read carefully — what does this print?
1#include <iostream>
2using namespace std;
3 
4int 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}

🎯 Your Answer