- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
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 Read Three Digits and Print all Possible Combinations from the Digits
Numbers are: a, b and c => 1, 2, 3
Combination of (a, b, c) are: (1, 1, 1), (1, 2, 1), (1, 2, 2), (1, 2, 3), . . ., (3, 3, 3).
Steps
- Define the variables, a, b and c.
- Print statement for the first number and scan the number.
- Print statement for the second number and scan the number.
- Print statement for the third number and scan the number.
- Initialize an array with numbers, a, b and c.
- Iterate the array with iterator i, j and k.
- Print (i, j, k)th index number of the array.
Example
package main import "fmt" func main(){ var a, b, c int fmt.Print("Enter first number: ") fmt.Scanf("%d", &a) fmt.Print("Enter second number: ") fmt.Scanf("%d", &b) fmt.Print("Enter third number: ") fmt.Scanf("%d", &c) arr := [3]int{a, b, c} for i := range arr{ for j := range arr{ for k := range arr{ fmt.Println(arr[i], arr[j], arr[k]) } } } }
Output
1 1 1 1 1 2 1 1 3 1 2 1 1 2 2 1 2 3 1 3 1 1 3 2 1 3 3 2 1 1 2 1 2 2 1 3 2 2 1 2 2 2 2 2 3 2 3 1 2 3 2 2 3 3 3 1 1 3 1 2 3 1 3 3 2 1 3 2 2 3 2 3 3 3 1 3 3 2 3 3 3
- Related Articles
- Python Program to Accept Three Digits and Print all Possible Combinations from the Digits
- Print all possible words from phone digits in C++
- Golang program to read and print all files from zip file
- How to generate a list of all possible 4 digits combinations in Excel?
- Golang Program to extract the last two digits from the given year
- Golang Program to read and print two-dimensional array
- Python Program to print all distinct uncommon digits present in two given numbers
- C++ program to convert all digits from the given range into words
- Write all possible 3- digit numbers (without repeating the digits) , by using the digits.(i)6,7,5 (ii) 9,0,2
- Golang Program to Count the Number of Digits in a Number
- Golang Program to Read Two Numbers and Print their Quotient and Remainder
- All possible numbers of N digits and base B without leading zeros?
- List all the three digit numbers can be made from the digits 0,5,9 without repetition.
- Finding all possible combinations from an array in JavaScript
- Python – How to Extract all the digits from a String

Advertisements