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 Go program that uses an if-else statement to check a person's age and print whether they can vote or not.
📋 What You'll Learn
Create an integer variable called
age with the value 20Create an integer variable called
votingAge with the value 18Use an
if-else statement to compare age with votingAgePrint
"You can vote!" if age is greater than or equal to votingAgePrint
"You cannot vote yet." if age is less than votingAge💡 Why This Matters
🌍 Real World
Checking age eligibility is common in many applications like voting, driving, or buying age-restricted items.
💼 Career
Understanding if-else statements is fundamental for decision-making in programming jobs.
Progress0 / 4 steps