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
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.
- Check Computer Science Books
- Watch Advanced C Programming Videos
- Practice Computer Science MCQs
- Apply for Computer Science Internship
- Practice BCA MCQs