This set of C Multiple Choice Questions & Answers (MCQs) focuses on “Pointers and Addresses – 2”.
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
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
Explanation: None.
3. What will be the output of the following C code?
#include <stdio.h>
int x = 0;
void main()
{
int *ptr = &x;
printf("%p\n", ptr);
x++;
printf("%p\n ", ptr);
}
a) Same address
b) Different address
c) Compile time error
d) Varies
View Answer
Explanation: None.
4. What will be the output of the following C code?
#include <stdio.h>
int x = 0;
void main()
{
int *const ptr = &x;
printf("%p\n", ptr);
ptr++;
printf("%p\n ", ptr);
}
a) 0 1
b) Compile time error
c) 0xbfd605e8 0xbfd605ec
d) 0xbfd605e8 0xbfd605e8
View Answer
Explanation: None.
5. What will be the output of the following C code?
#include <stdio.h>
void main()
{
int x = 0;
int *ptr = &x;
printf("%p\n", ptr);
ptr++;
printf("%p\n ", ptr);
}
a) 0xbfd605e8 0xbfd605ec
b) 0xbfd605e8 0cbfd60520
c) 0xbfd605e8 0xbfd605e9
d) Run time error
View Answer
Explanation: None.
6. What will be the output of the following C code?
#include <stdio.h>
void main()
{
int x = 0;
int *ptr = &5;
printf("%p\n", ptr);
}
a) 5
b) Address of 5
c) Nothing
d) Compile time error
View Answer
Explanation: None.
7. What will be the output of the following C code?
#include <stdio.h>
void main()
{
int x = 0;
int *ptr = &x;
printf("%d\n", *ptr);
}
a) Address of x
b) Junk value
c) 0
d) Run time error
View Answer
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.
- Get Free Certificate of Merit in C Programming
- Participate in C Programming Certification Contest
- Become a Top Ranker in C Programming
- Take C Programming Tests
- Chapterwise Practice Tests: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
- Chapterwise Mock Tests: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
- Buy C Books
- Buy Computer Science Books
- Practice BCA MCQs
- Apply for Computer Science Internship
- Apply for C Internship