Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Golang Program to create a string array that takes inputs from users.
Example

Approach
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.
Example
package main
import (
"fmt"
)
func main(){
fmt.Printf("Enter size of your array: ")
var size int
fmt.Scanln(&size)
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)
}
Output
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]
Advertisements