Bird
0
0

Find the error in this code snippet:

medium📝 Debug Q6 of 15
C - Operators and Expressions
Find the error in this code snippet:
int a = 1, b = 0;
if (a & b) {
printf("True");
} else {
printf("False");
}
AMissing semicolon after if statement
BVariables a and b are not initialized
CShould use && instead of & for logical AND
Dprintf syntax is incorrect
Step-by-Step Solution
Solution:
  1. Step 1: Identify operator used

    The code uses & which is bitwise AND, not logical AND.
  2. Step 2: Correct operator for condition

    Logical AND requires && to evaluate boolean expressions properly.
  3. Final Answer:

    Should use && instead of & for logical AND -> Option C
  4. Quick Check:

    Logical AND needs &&, not & [OK]
Quick Trick: Use && for logic, & is bitwise [OK]
Common Mistakes:
  • Using & instead of &&
  • Assuming & works like &&
  • Ignoring operator difference

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More C Quizzes