K-Map
August 28, 2024Pointers
August 28, 2024Pointers
|
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
int a, *b=&a, **c=&b;
a=4;
**c=5;
If the statement
b=(int *)**c
is appended to the above program fragment then
|
Value of b becomes 5
|
|
|
value of b will be the address of c
|
|
|
value of b is unaffected
|
|
|
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.
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.
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.
