(M) Pointer printsΒΆ

Goal: I will learn how use pointers in C++.

Instructions: Consider the example codes below and check the true claims.

Consider the code below:

1int x = 3;
2int* ptr = &x;
3cout << ptr << endl;
4cout << *ptr << endl;

Check the true claims based on the code above.

Consider the code below:

1int x;
2int* ptr = &x;
3x = 4;
4cout << ptr << endl;
5cout << *ptr << endl;

Check the true claims based on the code above.

Consider the code below:

1int x;
2int* ptr = &x;
3*ptr = 4;
4cout << ptr << endl;
5cout << *ptr << endl;

Check the true claims based on the code above.

Consider the code below:

1int x;
2int* ptr = 4;
3cout << ptr << endl;
4cout << *ptr << endl;

Check the true claims based on the code above.

Consider the code below:

1int x;
2int* ptr = &x;
3x = 5;
4cout << ptr << endl;
5cout << *ptr << endl;
6cout << x << endl;
7cout << &x << endl;

Check the true claims based on the code above.