Nested Conditional Statements
📖 Scenario: You are creating a simple program to check a person's age and determine their life stage. This is like asking a friend, "Are you a child, a teenager, or an adult?" based on their age.
🎯 Goal: Build a C program that uses nested if statements to decide if a person is a child, teenager, or adult based on their age.
📋 What You'll Learn
Create an integer variable called
age with the value 15.Create an integer variable called
child_age_limit and set it to 12.Use nested
if statements to check if age is less than or equal to child_age_limit, then print "Child".If not a child, check if
age is less than or equal to 19, then print "Teenager".If neither child nor teenager, print "Adult".
Print the result using
printf.💡 Why This Matters
🌍 Real World
Nested conditions help computers make decisions step-by-step, like deciding what message to show based on age.
💼 Career
Understanding nested conditionals is important for writing clear and correct decision-making code in many programming jobs.
Progress0 / 4 steps