C Programming Questions and Answers – Pointers to Pointers – 1

«
»

This set of C Multiple Choice Questions & Answers (MCQs) focuses on “Pointers to Pointers – 1”.

Pre-requisite for C Pointers to Pointers MCQ set: Video Tutorial on C Pointers.

advertisement

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

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

a) 5 5 5
b) 5 5 junk value
c) 5 junk junk
d) Run time error
View Answer

Answer: a
Explanation: None.
Note: Join free Sanfoundry classes at Telegram or Youtube
advertisement
advertisement

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

Take C Programming Practice Tests - Chapterwise!
Start the Test Now: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
advertisement
  1.     #include <stdio.h>
  2.     void main()
  3.     {
  4.         int k = 5;
  5.         int *p = &k;
  6.         int **m  = &p;
  7.         printf("%d%d%d\n", k, *p, **p);
  8.     }

a) 5 5 5
b) 5 5 junk value
c) 5 junk junk
d) Compile time error
View Answer

Answer: d
Explanation: None.
advertisement

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

  1.     #include <stdio.h>
  2.     void main()
  3.     {
  4.         int k = 5;
  5.         int *p = &k;
  6.         int **m  = &p;
  7.         **m = 6;
  8.         printf("%d\n", k);
  9.     }

a) 5
b) Compile time error
c) 6
d) Junk
View Answer

Answer: c
Explanation: None.
advertisement

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

  1.     #include <stdio.h>
  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
View Answer

Answer: b
Explanation: None.

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

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

a) Different address is printed
b) 1 2
c) Same address is printed
d) 1 1
View Answer

Answer: c
Explanation: None.

6. How many number of pointer (*) does C have against a pointer variable declaration?
a) 7
b) 127
c) 255
d) No limits
View Answer

Answer: d
Explanation: None.

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

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

a) ptr1 points to a
b) ptr1 points to b
c) sptr points to ptr2
d) none of the mentioned
View Answer

Answer: b
Explanation: None.

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

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

a) Different address is printed
b) 1 2
c) Same address is printed
d) 1 1
View Answer

Answer: c
Explanation: None.

Sanfoundry Global Education & Learning Series – C Programming Language.

To practice all areas of C language, here is complete set of 1000+ Multiple Choice Questions and Answers.

advertisement
advertisement

Leave a Comment

Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & technical discussions at Telegram SanfoundryClasses.