Bird
0
0

Identify the error in this C code using goto:

medium📝 Debug Q14 of 15
C - Loop Control Statements
Identify the error in this C code using goto:
int main() {
    goto end;
    printf("Hello");
    end:
    return 0;
}
ACannot jump over variable declarations.
BNo error; code runs and prints nothing.
CLabel 'end' is not defined.
DSyntax error in goto statement.
Step-by-Step Solution
Solution:
  1. Step 1: Check label definition and usage

    The label end is defined after the goto statement, so jumping to it is valid.
  2. Step 2: Analyze program flow

    The program jumps to end, skipping the printf. So it prints nothing and returns 0 without error.
  3. Final Answer:

    No error; code runs and prints nothing. -> Option B
  4. Quick Check:

    Jumping to label after goto is allowed [OK]
Quick Trick: Jumping forward to label is allowed; no error [OK]
Common Mistakes:
  • Thinking label must be before goto
  • Expecting output when skipped
  • Assuming syntax error in goto

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More C Quizzes