CPP

CPP

Dereferencing has 9 Questions

Which is used to tell the computer that where a pointer is pointing to?

dereference
reference
heap operations
none of the mentioned
Which is used to do the dereferencing?

pointer without asterix
value without asterix
pointer with asterix
value with asterix
Pick out the correct option.

References automatically dereference without needing an extra character.
References automatically dereference with an extra character.
Reference will not dereference
none of the mentioned
What is the output of this program?
  1.     #include 
  2.     using namespace std;
  3.     int main()
  4.     {
  5.         int a, b;
  6.         int* c;
  7.         c = &a;
  8.         a = 200;
  9.         b = 200;
  10.         *c = 100;
  11.         b = *c;
  12.         cout << *c << " " << b;
  13.         return 0;
  14.     }

100 200
100 0
200 200
100 100
What is the output of this program?
  1.     #include 
  2.     using namespace std;
  3.     int main() 
  4.     {
  5.         int x = 9;
  6.         int* p = &x;
  7.         cout << sizeof(p);
  8.         return 0;
  9.     }

4
2
Depends on compiler
none of the mentioned
What is the output of this program?
  1.     #include  
  2.     using namespace std;
  3.     int main()
  4.     {
  5.         double arr[] = {5.0, 6.0, 7.0, 8.0};
  6.         double *p = (arr+2);
  7.         cout << *p << endl;   
  8.         cout << arr << endl;  
  9.         cout << *(arr+3) << endl;
  10.         cout << *(arr) << endl;  
  11.         cout << *arr+9 << endl;  
  12.         return 0;
  13.     }

7 ????0xbf99fc98 ????8 ????5 ????14
7 ????8 ????0xbf99fc98 ????5 ????14
0xbf99fc98
none of the mentioned
Pick out the correct statement.

The NULL pointer dereference occurs where a pointer that is expected to be a valid address but instead is equal to NULL.
The NULL pointer dereference occurs where a pointer that is expected to be a valid address but instead is equal to memory address.
both a & b
none of the mentioned
What does the dereference operator will return?

rvalue equivalent to the value at the pointer address.
lvalue equivalent to the value at the pointer address.
it will return nothing
none of the mentioned
What is the output of this program?
  1.     #include 
  2.     using namespace std;
  3.     int main ()
  4.     {
  5.         int a;
  6.         int * ptr_b;
  7.         int ** ptr_c;
  8.         a = 1;
  9.         ptr_b = &a;
  10.         ptr_c = &ptr_b;
  11.         cout << a << "\n";
  12.         cout << *ptr_b << "\n";
  13.         cout << *ptr_c << "\n";
  14.         cout << **ptr_c << "\n";
  15.         return 0;
  16.     }

1 ????1 ????0xbffc9924 ????1
1 ????1 ????1 ????0xbffc9924
1 ????0xbffc9924 ????1 ????1
none of the mentioned