Initialize Employee Names Array

GolangGolangBeginner
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.


Skills Graph

%%%%{init: {'theme':'neutral'}}%%%% flowchart RL go(("Golang")) -.-> go/FunctionsandControlFlowGroup(["Functions and Control Flow"]) go(("Golang")) -.-> go/DataTypesandStructuresGroup(["Data Types and Structures"]) go/DataTypesandStructuresGroup -.-> go/strings("Strings") go/DataTypesandStructuresGroup -.-> go/arrays("Arrays") go/FunctionsandControlFlowGroup -.-> go/for("For") subgraph Lab Skills go/strings -.-> lab-436643{{"Initialize Employee Names Array"}} go/arrays -.-> lab-436643{{"Initialize Employee Names Array"}} go/for -.-> lab-436643{{"Initialize Employee Names Array"}} end

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
โœจ Check Solution and Practice

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.