Skip to main content
C Bug Hunt Easy +10 XP

Uninitialized Variable

This code has undefined behavior.

CFind the bug
1int x;
2printf("%d", x);
The bug is on line 1

Select the correct fix

Show answer and explanation

Answer: Both A and B fix it

Local variables in C are not automatically initialized. Reading an uninitialized variable is undefined behavior.

Hint: C doesn't zero-initialize local variables.

What this challenge tests

Bug Hunt in C: variables, undefined-behavior.

Related challenges