K-Map
August 28, 2024
Pointers
August 28, 2024
K-Map
August 28, 2024
Pointers
August 28, 2024

Pointers

Question 13
Consider the following declaration
int a, *b=&a, **c=&b;
a=4;
**c=5;
If the statement
b=(int *)**c
is appended to the above program fragment then
A
Value of b becomes 5
B
value of b will be the address of c
C
value of b is unaffected
D
none of these
Question 13 Explanation: 
In the given program fragment, three variables are there
Ordinary variable -a // value will be stored
Pointer variable -b // address of variable will be stored
Pointer to pointer variable(double pointer) -c // address of pointer variable will stored.
a=4 means storing/assigning value to “a”.
**c means value at(value at(c)) =value at(value at(&b)) (c holds address of pointer “b”)
=value at(&a) (b holds the address of “a”)
Memory location of variable “a”, value 5 is
stored/assigned into the variable.
Given statement is b=(int *)**c. So the value of b becomes 5.
Correct Answer: A
Question 13 Explanation: 
In the given program fragment, three variables are there
Ordinary variable -a // value will be stored
Pointer variable -b // address of variable will be stored
Pointer to pointer variable(double pointer) -c // address of pointer variable will stored.
a=4 means storing/assigning value to “a”.
**c means value at(value at(c)) =value at(value at(&b)) (c holds address of pointer “b”)
=value at(&a) (b holds the address of “a”)
Memory location of variable “a”, value 5 is
stored/assigned into the variable.
Given statement is b=(int *)**c. So the value of b becomes 5.

Leave a Reply

Your email address will not be published. Required fields are marked *