Why arrays are needed
📖 Scenario: Imagine you want to store the scores of 5 players in a game. Instead of creating 5 separate variables, you can use an array to keep all scores together.
🎯 Goal: You will create an array to hold 5 player scores, set a threshold score, find which players scored above the threshold, and print their scores.
📋 What You'll Learn
Create an integer array called
scores with exactly these values: 50, 75, 60, 85, 40Create an integer variable called
threshold and set it to 60Use a
for loop with variable i to find scores greater than threshold and store them in an array called highScoresPrint the
highScores array elements separated by spaces💡 Why This Matters
🌍 Real World
Arrays are used in games, apps, and websites to store lists like scores, names, or settings.
💼 Career
Understanding arrays is essential for programming jobs because they help manage data efficiently.
Progress0 / 4 steps