Golang program to create an integer array that takes inputs from users.



  • Ask the user to enter the size of array.

  • Make an integer array of given size.

  • Ask the user to enter 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([]int, size)
   for i:=0; i<size; i++ {
      fmt.Printf("Enter %dth element: ", i)
      fmt.Scanf("%d", &arr[i])
   fmt.Println("Your array is: ", arr)


Enter size of your array: 6
Enter 0th element: 10
Enter 1th element: 20
Enter 2th element: 30
Enter 3th element: 40
Enter 4th element: 50
Enter 5th element: 60
Your array is: [10 20 30 40 50 60]