Here is a listing of C quiz on “Pointer Addresses” along with answers, explanations and/or solutions:
1. What is the output of this C code?
a) nullp nullq
b) Depends on the compiler
c) x nullq where x can be p or nullp depending on the value of NULL
d) p q
View Answer
b) Depends on the compiler
c) x nullq where x can be p or nullp depending on the value of NULL
d) p q
View Answer
Answer:a
2. What is the output of this C code?
a) Compile time error
b) Segmentation fault/runtime crash
c) 10
d) Undefined behaviour
View Answer
b) Segmentation fault/runtime crash
c) 10
d) Undefined behaviour
View Answer
Answer:a
3. What is the output of this C code?
a) Compile time error
b) Undefined behaviour
c) 10
d) 0.000000
View Answer
b) Undefined behaviour
c) 10
d) 0.000000
View Answer
Answer:d
4. What is the output of this C code?
a) 10
b) Compile time error
c) Segmentation fault/runtime crash since pointer to local variable is returned
d) Undefined behaviour
View Answer
b) Compile time error
c) Segmentation fault/runtime crash since pointer to local variable is returned
d) Undefined behaviour
View Answer
Answer:a
5. What is the output of this C code?
a) 10
b) Compile time error
c) Segmentation fault/runtime crash
d) Undefined behaviour
View Answer
b) Compile time error
c) Segmentation fault/runtime crash
d) Undefined behaviour
View Answer
Answer:a
6. Comment on the following pointer declaration?
int *ptr, p;
a) ptr is a pointer to integer, p is not
b) ptr and p, both are pointers to integer
c) ptr is a pointer to integer, p may or may not be
d) ptr and p both are not pointers to integer
View Answer
int *ptr, p;
a) ptr is a pointer to integer, p is not
b) ptr and p, both are pointers to integer
c) ptr is a pointer to integer, p may or may not be
d) ptr and p both are not pointers to integer
View Answer
Answer:a
7. What is the output of this C code?
a) 10,10
b) 10,11
c) 11,10
d) 11,11
View Answer
b) 10,11
c) 11,10
d) 11,11
View Answer
Answer:d
8. Comment on the following?
const int *ptr;
a) You cannot change the value pointed by ptr
b) You cannot change the pointer ptr itself
c) Both (a) and (b)
d) You can change the pointer as well as the value pointed by it
View Answer
const int *ptr;
a) You cannot change the value pointed by ptr
b) You cannot change the pointer ptr itself
c) Both (a) and (b)
d) You can change the pointer as well as the value pointed by it
View Answer
Answer:a
www.cinterviews.com appreciates your contribution please mail us the questions you have to cinterviews.blogspot.com@gmail.com so that it will be useful to our job search community
No comments:
Post a Comment