Bird
0
0

Which of the following is the correct syntax for an if statement in C?

easy📝 Syntax Q12 of 15
C - onditional Statements
Which of the following is the correct syntax for an if statement in C?
Aif (condition) { /* code */ }
Bif condition { /* code */ }
Cif condition then { /* code */ }
Dif [condition] { /* code */ }
Step-by-Step Solution
Solution:
  1. Step 1: Recall C syntax for if statements

    In C, conditions must be inside parentheses and code inside braces.
  2. Step 2: Check each option

    if (condition) { /* code */ } matches the correct syntax: if (condition) { /* code */ }.
  3. Final Answer:

    if (condition) { /* code */ } -> Option A
  4. Quick Check:

    Parentheses around condition = correct syntax [OK]
Quick Trick: Remember: if (condition) { } in C [OK]
Common Mistakes:
  • Omitting parentheses around condition
  • Using square brackets instead of parentheses
  • Adding 'then' keyword which C does not use

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More C Quizzes