If Statement Basics in C
📖 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 C program that uses an if 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
voting_age with the value 18Use an
if 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, or buying age-restricted products.
💼 Career
Understanding if statements is fundamental for any programming job because it helps make decisions in code.
Progress0 / 4 steps