![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
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 traverse a given input array, with Boolean flag, using arrays and struct.
Example
Approach
Ask the user to enter the size of array.
Make a string array of given size.
Ask the user to enter elements.
At the end, print the array.
Example
package main import "fmt" func main(){ arr := []int{10, 20, 30, 60, 40, 50} boolArr := []bool{true, false, true, false, true, false} fmt.Println("Input Array is: ", arr) fmt.Println("Input Boolean Array is: ", boolArr) visitedArray := []struct{ i int b bool }{ {10, true}, {20, false}, {30, true}, {60, false}, {40, true}, {50, false}, } fmt.Println("Boolean array using struct: ", visitedArray) }
Output
Input Array is: [10 20 30 60 40 50] Input Boolean Array is: [true false true false true false] Boolean array using struct: [{10 true} {20 false} {30 true} {60 false} {40 true} {50 false}]
Advertisements