Why arrays are needed
📖 Scenario: Imagine you run a small shop and want to keep track of the prices of exactly 5 different fruits you sell every day.
🎯 Goal: You will create a program that stores the prices of 5 fruits using an array, then calculates the total cost if you buy one of each fruit.
📋 What You'll Learn
Create an array called
fruitPrices with exactly 5 decimal values representing prices.Create a variable called
totalCost to hold the sum of all prices.Use a
for loop with the variable i to add each price in fruitPrices to totalCost.Print the
totalCost with a message.💡 Why This Matters
🌍 Real World
Stores lists of items like prices, names, or measurements to manage data efficiently.
💼 Career
Understanding arrays is essential for programming jobs that handle collections of data, like software development and data analysis.
Progress0 / 4 steps