Bird
0
0

You want to write a program that prints "Child", "Teen", or "Adult" based on age using else-if ladder. Which code correctly implements this?

hard📝 Application Q8 of 15
C - onditional Statements
You want to write a program that prints "Child", "Teen", or "Adult" based on age using else-if ladder. Which code correctly implements this?
int age = 16;
if (age < 13) {
  printf("Child\n");
} else if (age < 20) {
  printf("Teen\n");
} else {
  printf("Adult\n");
}
APrints "Adult" for age 16
BPrints "Child" for age 16
CCorrectly prints "Teen" for age 16
DCode has syntax error
Step-by-Step Solution
Solution:
  1. Step 1: Analyze conditions with age = 16

    First condition (age < 13) is false, second (age < 20) is true, so it prints "Teen".
  2. Step 2: Check syntax correctness

    All conditions have parentheses and braces; syntax is correct.
  3. Final Answer:

    Correctly prints "Teen" for age 16 -> Option C
  4. Quick Check:

    Else-if ladder correctly categorizes age [OK]
Quick Trick: Check conditions in order for correct category [OK]
Common Mistakes:
  • Misclassifying age 16 as Child or Adult
  • Missing braces causing syntax errors
  • Incorrect condition order

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More C Quizzes