250+ TOP MCQs on Pointers to Pointers and Answers

C helps anyone preparing for Mindtree and other companies C interviews. One should practice these Objective Questions and answers continuously for 2-3 months to clear Mindtree interviews on C Programming language.

Here is a listing of C programming questions on “Pointers to Pointers” along with answers, explanations and/or solutions:

1. What substitution should be made to //-Ref such that ptr1 points to variable c in the following C code?

  1.     #include 
  2.     int main()
  3.     {
  4.         int a = 1, b = 2, c = 3;
  5.         int *ptr1 = &a;
  6.         int **sptr = &ptr1;
  7.         //-Ref
  8.     }

a) *sptr = &c;
b) **sptr = &c;
c) *ptr1 = &c;
d) none of the mentioned
Answer: a
Clarification: None.

2. Which of the following declaration will result in run-time error?
a) int **c = &c;
b) int **c = &*c;
c) int **c = **c;
d) none of the mentioned
Answer: d
Clarification: None.

3. Comment on the output of the following C code.

  1.     #include 
  2.     int main()
  3.     {
  4.         int a = 10;
  5.         int **c -= &&a;
  6.     }

a) You cannot apply any arithmetic operand to a pointer
b) We don’t have address of an address operator
c) We have address of an address operator
d) None of the mentioned
Answer: b
Clarification: None.

4. What will be the output of the following C code?

  1.     #include 
  2.     void main()
  3.     {
  4.         int k = 5;
  5.         int *p = &k;
  6.         int **m  = &p;
  7.         printf("%d%d%dn", k, *p, **m);
  8.     }

a) 5 5 5
b) 5 5 junk value
c) 5 junk junk
d) Compile time error
Answer: a
Clarification: None.

5. What will be the output of the following C code?

  1.     #include 
  2.     void main()
  3.     {
  4.         int k = 5;
  5.         int *p = &k;
  6.         int **m  = &p;
  7.         printf("%d%d%dn", k, *p, **p);
  8.     }

a) 5 5 5
b) 5 5 junk value
c) 5 junk junk
d) Compile time error
Answer: d
Clarification: None.

6. What will be the output of the following C code?

  1.     #include 
  2.     void main()
  3.     {
  4.         int k = 5;
  5.         int *p = &k;
  6.         int **m  = &p;
  7.         **m = 6;
  8.         printf("%dn", k);
  9.     }

a) 5
b) Run time error
c) 6
d) Junk
Answer: c
Clarification: None.

7. What will be the output of the following C code?

  1.     #include 
  2.     void main()
  3.     {
  4.         int a[3] = {1, 2, 3};
  5.         int *p = a;
  6.         int *r = &p;
  7.         printf("%d", (**r));
  8.     }

a) 1
b) Compile time error
c) Address of a
d) Junk value
Answer: b
Clarification: None.

  250+ TOP MCQs on Formatted Output and Answers

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top