This set of C Multiple Choice Questions & Answers (MCQs) focuses on “Pointers to Pointers – 2”.
Pre-requisite for C Pointers to Pointers MCQ set: Video Tutorial on C Pointers.
1. What substitution should be made to //-Ref such that ptr1 points to variable c in the following C code?
#include <stdio.h>
int main()
{
int a = 1, b = 2, c = 3;
int *ptr1 = &a;
int **sptr = &ptr1;
//-Ref
}
a) *sptr = &c;
b) **sptr = &c;
c) *ptr1 = &c;
d) none of the mentioned
View Answer
Explanation: None.
2. Which of the following declaration will result in run-time error?
a) int **c = &c;
b) int **c = &*c;
c) int **c = **c;
d) none of the mentioned
View Answer
Explanation: None.
3. Comment on the output of the following C code.
#include <stdio.h>
int main()
{
int a = 10;
int **c -= &&a;
}
a) You cannot apply any arithmetic operand to a pointer
b) We don’t have address of an address operator
c) We have address of an address operator
d) None of the mentioned
View Answer
Explanation: None.
4. What will be the output of the following C code?
#include <stdio.h>
void main()
{
int k = 5;
int *p = &k;
int **m = &p;
printf("%d%d%d\n", k, *p, **m);
}
a) 5 5 5
b) 5 5 junk value
c) 5 junk junk
d) Compile time error
View Answer
Explanation: None.
5. What will be the output of the following C code?
#include <stdio.h>
void main()
{
int k = 5;
int *p = &k;
int **m = &p;
printf("%d%d%d\n", k, *p, **p);
}
a) 5 5 5
b) 5 5 junk value
c) 5 junk junk
d) Compile time error
View Answer
Explanation: None.
6. What will be the output of the following C code?
#include <stdio.h>
void main()
{
int k = 5;
int *p = &k;
int **m = &p;
**m = 6;
printf("%d\n", k);
}
a) 5
b) Run time error
c) 6
d) Junk
View Answer
Explanation: None.
7. What will be the output of the following C code?
#include <stdio.h>
void main()
{
int a[3] = {1, 2, 3};
int *p = a;
int *r = &p;
printf("%d", (**r));
}
a) 1
b) Compile time error
c) Address of a
d) Junk value
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.
If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]
- Check C Books
- Watch Advanced C Programming Videos
- Practice Computer Science MCQs
- Apply for Computer Science Internship
- Practice BCA MCQs