For loop with ranges
📖 Scenario: You are helping a small bakery count how many cupcakes they have baked each day over a week.
🎯 Goal: Build a Kotlin program that uses a for loop with a range to count cupcakes baked from day 1 to day 7.
📋 What You'll Learn
Create a variable called
totalCupcakes and set it to 0Create a
for loop using day in the range 1 to 7Inside the loop, add 10 cupcakes for each day to
totalCupcakesPrint the final value of
totalCupcakes💡 Why This Matters
🌍 Real World
Counting items or events over a fixed number of days or steps is common in business and daily life.
💼 Career
Understanding loops and ranges helps automate repetitive tasks and process data efficiently in software development.
Progress0 / 4 steps