What will happen in the following C++ code? extern void display(); int main() { display(); }?

  • AProgram runs successfully
  • BCompile-time syntax error
  • CUndefined reference (linker error)
  • DInfinite loop
Show answerHide answer

Correct answer C

The extern keyword declares a function without providing its definition. display() is called in main, but the compiler cannot find its actual implementation. Compilation passes the syntax check, but linking fails. The linker reports an undefined reference error.