Embedded Systems & Hardware
Qualcomm technical mcq question, verified with a worked answer. Free to practise - no sign-up.
int function(int UNO())
{
UNO[5]; //line 1
return 0;
}
Show answer & explanation
Answer: A. It will show compile time error
The function parameter int UNO() declares UNO as a function pointer (a function that takes no arguments and returns int), not an array. The statement UNO[5] attempts to subscript a function pointer as if it were an array, which is invalid syntax. The compiler will reject this with a compile-time error because you cannot use array subscript notation on a function type.
Step-by-step Derivation:
Step-by-step analysis:
int function(int UNO())declares a function that accepts a parameter UNO, which is itself a function (returning int, taking no parameters).- Inside the function body,
UNO[5]attempts to use subscript notation[]on UNO. - Since UNO is a function type (not an array or pointer-to-array), applying the subscript operator is a syntax error.
- The C compiler will reject this code at compile time with an error like "subscripted value is neither array nor pointer" or similar.
- Options B, C, D (numerical values) are not reachable because compilation fails before execution.
- Therefore, the answer is A: compile time error.