Correct option is B
1.
Variable Initialization: x is declared and initialized to 10.
2.
Pointer Initialization: a is declared as a pointer to an integer and initialized to the address of x. Now, *a points to x.
3.
Dereferencing and Modification: *a = *a + 5; This statement adds 5 to the value pointed to by a, which is x. So: x = x + 5 = 15.
4.
Output: printf("%d\n", *a); prints the value of x, which is now 15.
Key Points:
1. Dereferencing a pointer (*a) accesses the value stored at the memory address it points to.
2. Modifying *a directly updates the value of x since a points to the memory location of x.
Knowledge Booster:
·
Pointer Basics: A pointer stores the address of a variable, and dereferencing a pointer (*) allows access to the value stored at that address.
·
Use Case: Pointers are crucial for dynamic memory management, function arguments (pass by reference), and data structures like linked lists.