Golang Program to create a string array that takes inputs from users.



  • Ask the user to enter the size of array.

  • Make a string array of given size.

  • Ask the user to enter the elements.

  • At the end, print the array.


 Live Demo

package main
import (
func main(){
   fmt.Printf("Enter size of your array: ")
   var size int
   var arr = make([]string, size)
   for i:=0; i<size; i++ {
      fmt.Printf("Enter %dth element: ", i)
      fmt.Scanf("%s", &arr[i])
   fmt.Println("Your array is: ", arr)


Enter size of your array: 6
Enter 0th element: g
Enter 1th element: o
Enter 2th element: l
Enter 3th element: a
Enter 4th element: n
Enter 5th element: g
Your array is: [g o l a n g]