in Programming in C edited by
897 views
1 vote
1 vote

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

  1. Value of $b$ becomes $5$
  2. Value of $b$ will be the address of $c$
  3. Value of $b$ is unaffected
  4. None of these
in Programming in C edited by
by
897 views

3 Answers

1 vote
1 vote
c is pointing to the address of b which itself points to the integer a.

Now, *c = b && **c = *b = a = 5

so, according to me : b = 5(address not a value).

b contain the data present at memory address 5.

OPTION D
0 votes
0 votes
Value of b is already 5 as **c=5 means a=5 also.And b is also pointing a so,b=5
by
0 votes
0 votes
Value of b will be the address of c.

The statement b = (int *)**c; changes the value of b to the address stored in c, which is the address of b. This is because **c returns the value stored at the address stored in c, which is the address of b. The type cast (int *) is used to ensure that the value stored in c is treated as a pointer to an int.

So, the value of b will now be the address of b, not 5.
Answer:

Related questions