Why loops are needed
📖 Scenario: Imagine you have a list of 5 friends and you want to say "Hello" to each one. Writing the same line again and again is tiring and takes a lot of space. Loops help us repeat actions easily without writing the same code many times.
🎯 Goal: You will create a simple program that stores 5 friend names and uses a loop to greet each friend by printing "Hello, <friend>!".
📋 What You'll Learn
Create an array of 5 friend names
Create a variable to count how many friends there are
Use a for loop to go through each friend in the array
Print a greeting message for each friend
💡 Why This Matters
🌍 Real World
Loops are used in many programs to handle repeated tasks like processing lists of data, automating repetitive actions, and managing user inputs.
💼 Career
Understanding loops is essential for any programming job because they make code efficient and easier to maintain when working with collections of data.
Progress0 / 4 steps