Question 6 Select any one of the following options
Palo Alto Networks technical mcq question, verified with a worked answer. Free to practise - no sign-up.
int main(void) {
int a[]={0,1,2,3,4};
int *p;
for(p=a+4;p>=a;p--)
printf("%d ",*ptr-a]);
return 0;
}
Select any one of the following options
Show answer & explanation
Answer: D. D) COMPILATION ERROR
The expression *ptr-a] contains an unmatched closing bracket and an undeclared identifier ptr, causing a compilation error.
Step-by-step Derivation:
Step 1: Inspect the print statement: printf("%d ", *ptr-a]);
Step 2: The identifier ptr has not been declared (only p is declared).
Step 3: The syntax *ptr-a] has an unmatched bracket ']', leading to a fatal compiler syntax error.