Question 8 Select any one of the following
Palo Alto Networks technical mcq question, verified with a worked answer. Free to practise - no sign-up.
Question 8
int main(void)
{
int a[2][3][2]={{{1,2},{3,4},{5,6}},{{7,8},{9,10},{11,12}}};
printf("%d %d",a[1]-a[0],a[1][0]-a[0][0]);
return 0;
}
**Select any one of the following
Show answer & explanation
Answer: A. A) 3,6
a[1] and a[0] decay to pointers to int[2]. The distance between them is 3 elements of int[2]. a[1][0] and a[0][0] decay to int*, and the distance between them is 3 * 2 = 6 integers. The output is 3,6.
Step-by-step Derivation:
Step 1: 'a' has type int[2][3][2]. a[0] and a[1] each contain 3 rows of 2 integers.
Step 2: In expression a[1] - a[0], both decay to pointers of type int()[2]. The distance in terms of int[2] elements is 3.
Step 3: In expression a[1][0] - a[0][0], both decay to int. The total number of integers between them is 3 * 2 = 6.
Step 4: The printed output is 3,6.