CJCoding With Joseph
15free / daySign inCreate account
Back to Code Walkthrough

Pointer Arithmetic

C++ code walkthrough · Question 2
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