Why control flow directs execution
📖 Scenario: Imagine you are organizing a small event and need to decide what to do based on the weather forecast.
🎯 Goal: You will write a simple R program that uses control flow to decide what activity to do depending on the weather.
📋 What You'll Learn
Create a variable called
weather with the value "sunny"Create a variable called
activity and set it to an empty stringUse an
if statement to set activity to "Go for a walk" if weather is "sunny"Use an
else if statement to set activity to "Read a book indoors" if weather is "rainy"Use an
else statement to set activity to "Stay home and relax" for any other weatherPrint the value of
activity💡 Why This Matters
🌍 Real World
Control flow is used in real life to make decisions, like choosing what to do based on the weather or other conditions.
💼 Career
Understanding control flow is essential for programming jobs because it allows software to react differently depending on inputs or situations.
Progress0 / 4 steps