C Programming Questions and Answers – Pointers and Addresses

This set of C Multiple Choice Questions & Answers (MCQs) focuses on “Pointers and Addresses”.

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

1. Which is an indirection operator among the following?
a) &
b) *
c) ->
d) .
View Answer

Answer: b
Explanation: None.

2. Which of the following does not initialize ptr to null (assuming variable declaration of a as int a=0;)?
a) int *ptr = &a;
b) int *ptr = &a – &a;
c) int *ptr = a – a;
d) All of the mentioned
View Answer

Answer: a
Explanation: None.
advertisement
advertisement

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

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

a) Same address
b) Different address
c) Compile time error
d) Varies
View Answer

Answer: a
Explanation: None.
Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!

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

advertisement
  1.     #include <stdio.h>
  2.     int x = 0;
  3.     void main()
  4.     {
  5.         int *const ptr = &x;
  6.         printf("%p\n", ptr);
  7.         ptr++;
  8.         printf("%p\n ", ptr);
  9.     }

a) 0 1
b) Compile time error
c) 0xbfd605e8 0xbfd605ec
d) 0xbfd605e8 0xbfd605e8
View Answer

Answer: b
Explanation: None.
advertisement

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

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

a) 0xbfd605e8 0xbfd605ec
b) 0xbfd605e8 0cbfd60520
c) 0xbfd605e8 0xbfd605e9
d) Run time error
View Answer

Answer: a
Explanation: None.

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

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

a) 5
b) Address of 5
c) Nothing
d) Compile time error
View Answer

Answer: d
Explanation: None.

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

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

a) Address of x
b) Junk value
c) 0
d) Run time error
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
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 & discussions at Telegram SanfoundryClasses.