Multiple choice technology programming languages

What is the value of x when the below code segment is executed? int main() { int x , *z ; x = 10 ; z = &x ; x = 20 ; *z = 10 ; }

  1. 10

  2. 20

  3. Compilation Error

  4. RuntimeError

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

The pointer z stores the address of x. Initially x=10, then x=20 overwrites it. When *z=10 executes, it dereferences the pointer and modifies the value at address z, which is x. This changes x back to 10. The final value of x is 10.