This code has undefined behavior.
int x;
printf("%d", x);
Initialize x before use: int x = 0
Use scanf to read x first
Both A and B fix it
Cast x to int