If-else statement
📖 Scenario: You are creating a simple program that checks if a person is old enough to vote.
🎯 Goal: Build a program that uses an if-else statement to decide if a person can vote based on their age.
📋 What You'll Learn
Create an integer variable called
age with the value 20Create an integer variable called
voting_age with the value 18Use an
if-else statement to check if age is greater than or equal to voting_agePrint
"You can vote." if the condition is truePrint
"You cannot vote yet." if the condition is false💡 Why This Matters
🌍 Real World
Checking age eligibility is common in many real-world applications like voting, driving licenses, or age-restricted content.
💼 Career
Understanding if-else statements is fundamental for any programming job because it helps programs make decisions based on conditions.
Progress0 / 4 steps