If-else statement
📖 Scenario: You are creating a simple program to check if a person is old enough to vote. Voting age is 18 years or older.
🎯 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 and set it to 18Use an
if-else statement to check if age is greater than or equal to voting_agePrint
"You are eligible to vote." if the condition is truePrint
"You are not eligible to vote." if the condition is false💡 Why This Matters
🌍 Real World
Checking age eligibility is common in many real-life situations like voting, driving, or drinking alcohol.
💼 Career
Understanding if-else statements is essential for any programming job because it helps programs make decisions.
Progress0 / 4 steps