CJCoding With Joseph
15free / daySign inCreate account
โ† 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