Multiple choice technology programming languages

Which of the following will occur when trying to validate the below code Segment? #define #define // GetSquareOfx function-prototype has the following defn // int GetSquareOfx(int) ; Int main() { int x =5 ; Cout << GetSquareOfx() ; return x ; }

  1. Syntax Error

  2. Linker Error

  3. Runtme Error

  4. No Error, It will be run successfully

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

The code declares a function prototype int GetSquareOfx(int) but never provides the function definition. When the linker tries to resolve the function call GetSquareOfx(), it fails because the definition is missing. This produces a linker error (undefined reference), not a syntax error (which would be caught during compilation).

AI explanation

The header only supplies the function prototype (int GetSquareOfx(int);) — a declaration, not a definition. The compiler is satisfied by the declaration and produces object code for the call, so compilation succeeds. When the linker then tries to resolve the call to GetSquareOfx, it finds no matching definition in any object file or library and reports an 'undefined reference' — a Linker Error.