- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- 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 an integer array that takes inputs from users.
Example
Approach
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.
Example
package main import ( "fmt" ) func main(){ fmt.Printf("Enter size of your array: ") var size int fmt.Scanln(&size) 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) }
Output
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]
- Related Articles
- Golang Program to create a string array that takes inputs from users.
- Golang Program To Remove Duplicates From An Array
- Golang Program to Remove Repeated Elements From an Array
- Golang program to remove all elements from an array
- Golang Program To Remove Duplicate Elements From An Array
- Golang Program to Create an Interface
- Golang Program to convert an integer into binary representation
- Golang program to print an array?
- Golang Program To Sort An Array
- Golang Program to count the set bits in an integer.
- Golang Program to Find the Smallest Divisor of an Integer
- Golang Program to Generate all the Divisors of an Integer
- Golang Program To Get The Successor Of An Integer Number
- Golang Program To Push An Array Into Another Array
- Golang Program To Append An Element Into An Array

Advertisements