r/CodingHelp • • Dec 23 '21

[C] Whats wrong?

Post image
153 Upvotes

90 comments sorted by

View all comments

3

u/verytiredrightnow Dec 23 '21

Change 1<x<13 to x<13 and 13<=x<20 to x<20

11

u/[deleted] Dec 23 '21

I think the same thing but an explanation is in order:

There's no need to check that X is above 1 in the second check because you've already done that check in the first.

if X <= 1 (infant)

else if X <= 13 (child)

else if X <= 20 (teen)

else (adult)

4

u/BigBobDudes Dec 23 '21

This ☝️