Initialize Employee Names Array

GolangBeginner
Practice Now

Introduction

In this challenge, you will create a simple Go program to store and display employee names using arrays. As an HR assistant in a small tech startup, efficiently managing team information is crucial, and this exercise will help you practice working with arrays in Go.

Initialize Employee Names Array

In a small tech startup, managing team information efficiently is crucial. As an HR assistant, you'll create a simple Go program to store and display employee names using arrays.

Tasks

  • Create an array to store exactly 5 employee names
  • Use the range-based for loop to print out all employee names

Requirements

  • Create the program in ~/project/employees.go
  • Use an array with exactly 5 string elements
  • Initialize the array with real or fictional employee names (see examples)
  • Use a range-based for loop to print the array
  • The program must compile and run without errors

Examples

Run the program to display the employee names:

go run employees.go

Example output:

0 John Smith
1 Emily Chen
2 Michael Rodriguez
3 Sarah Kim
4 David Lee

Hints

  • Remember that array indices start from 0
  • Use the range keyword to iterate through the array
  • Each iteration of the range loop provides both index and value

Summary

In summary, this challenge requires you to create a Go program that stores and displays a list of 5 employee names using an array. You will need to initialize the array with real or fictional employee names and then use a range-based for loop to print out all the names.

✨ Check Solution and Practice