Q53
Which of the following statements are true after execution of the program. void main() int a[10], i, *p; a[0] = 1; a[1] = 2; p = a; (*p)++;
A.
a[1] = 3
B.
a[0] = 2
AnswerC.
a[1] = 1
D.
a[0] = 3
E.
Compilation error
Answer: Option B
Solution
Answer: Option B
Solution:
After the execution of the program, the value of the first element of the array 'a' will be modified. Let's break down the code step by step:a[0] = 1;: Sets the first element of the array 'a' to 1.
a[1] = 2;: Sets the second element of the array 'a' to 2.
p = a;: Assigns the address of the first element of the array 'a' to the pointer 'p'.
(*p)++;: Increments the value at the memory location pointed to by 'p'. Since 'p' points to the first element of 'a', it increments the value of 'a[0]'.
After the execution of the program, the value of a[0] will be 2.
Therefore, the correct statement is Option B: a[0] = 2.