OA. free
Free
Qualcomm Embedded Systems & Hardware Embedded Systems & Hardware Medium

What will be the output of this code?

Qualcomm technical mcq question, verified with a worked answer. Free to practise - no sign-up.

int myregister int x, register int y)
{
    static int i;
    for(i = 0; i < i; i++)
    {
        x += 2;
        y += 2;
    }
}

What will be the output of this code?

Choose one option.
Show answer & explanation
Answer: D. Compile time error

The function declaration has a syntax error: int myregister int x, register int y) is missing the opening parenthesis after myregister. This is a malformed function declaration that will cause the compiler to fail during the compilation phase. The code will not compile, so no runtime output is possible.

Step-by-step Derivation:
Step-by-step analysis:

  1. Parse the function declaration: int myregister int x, register int y)
  2. Expected syntax: int myregister(int x, register int y)
  3. Missing opening parenthesis ( after function name myregister
  4. The compiler encounters an unexpected token int where it expects (, raising a syntax error
  5. Compilation fails before any runtime execution
  6. Result: Compile time error

Note: Even if the syntax were corrected, the loop condition i < i would always be false (0 < 0 is false), so the loop body would never execute, and the function would return without output.