Array length
📖 Scenario: You are working on a program that needs to know how many items are in a list of fruits. This is common when you want to count things in real life, like how many apples you have in a basket.
🎯 Goal: Build a Go program that creates an array of fruits, then finds and prints the length of that array.
📋 What You'll Learn
Create an array called
fruits with exactly these values: "apple", "banana", "cherry", "date"Create a variable called
length that stores the length of the fruits arrayPrint the value of
length to show how many fruits are in the array💡 Why This Matters
🌍 Real World
Counting items in a list is common in many programs, like counting products in a shopping cart or names in a guest list.
💼 Career
Knowing how to find the length of arrays or lists is a basic skill for programming jobs that involve data processing or user input.
Progress0 / 4 steps