If statement
📖 Scenario: You are creating a simple program that checks if a number is positive or not. This is like checking if the temperature outside is above zero degrees to decide if you need a jacket.
🎯 Goal: Build a program that uses an if statement to check if a number is positive and prints a message accordingly.
📋 What You'll Learn
Create an integer variable called
number with the value 10Create a boolean variable called
isPositive that will store if the number is positiveUse an
if statement to set isPositive to true if number is greater than 0Print
"The number is positive" if isPositive is true💡 Why This Matters
🌍 Real World
Checking conditions like this helps programs make decisions, such as turning on a heater if the temperature is cold.
💼 Career
Understanding if statements is essential for any programming job because it controls the flow of decisions in software.
Progress0 / 4 steps