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
Programming Articles - Page 470 of 3363
921 Views
In this tutorial, we will learn how to fetch elements from an array with the help of index using different examples to showcase what methods can be applied to it and the result obtained will be printed on the console using the print function in Golang. Method 1: Using an Array Index In this method, we will see how to fetch element from an array using index in for loop and this is one of the simplest methods to solve this problem, lets have a look at this example to understand it. Algorithm Step 1 − Create a package main ... Read More
4K+ Views
In this tutorial, we will learn how to remove an element from an array using simple for loop approach. The logic behind this approach is that create a new array and the particular index element which is to be removed don’t add it to the new array. Let’s have a look how to execute it with the use of different examples. Remove Element from the Array in main Function In this method, we will execute the entire program inside main function. An original array and a new array will be created to execute the removal of elements from the array. ... Read More
191 Views
In this tutorial, we will see how strings are created in Golang. There are different ways to create strings which we will learn via some examples. In Golang a string is a sequence of variable-width characters where each character is represented by one or more bytes. Method 1: Using double Quotes with Shorthand Declaration In this method, we will learn about how to create strings using shorthand declaration. Let’s dive into the code to understand it. Algorithm Step 1 − Create a package main and import fmt package in the program. Step 2 − Create a function main and further ... Read More
302 Views
In this tutorial, we will see how to search an item in the array using interpolation search. It is very similar to Binary search but is an improved version of it, in this algorithm the element is searched from the sorted array using a different method to find middle element and the output is printed using print function in Golang. Let’s have a look to understand it − Using interpolation search in main method In this method, we will learn how to search an element in the array using an interpolation search method. All the things will be executed in ... Read More
754 Views
In this article we will write an article to compare numbers and strings using library function in Go language. we will write two programs to illustrate. In the first program we will use the external user defined function and in the second one we will use the internal library function to implement the logic. Syntax func Compare(s1, s2 string) int Compare() function is used to compare the given strings in go. It is present in strings package. This function takes the strings to be compared as argument to the function and returns the integer equivalent after comparing the two ... Read More
609 Views
In this tutorial, we will learn how to convert Boolean to a string in Go programming language. Boolean is a data type having 1 byte size. It can store any one of the three values mainly True, False or none. String data type is used to store a sequence of characters. Convert Boolean Variables to String using FormatBool() Functions Syntax func FormatBool(b bool) string This function is present in strconv package. FormatBool() function is used to convert a Boolean variable to string. The function takes the Boolean value as an argument and returns a string. Algorithm STEP 1 − ... Read More
319 Views
In this tutorial, we will learn how to print hollow star triangle pattern using Go programming language. The user can specify the maximum number of rows to print as an inverted pyramid star pattern using this GO programmed. Here, we'll print the inverted Pyramid of * symbols up till the user-specified rows are reached. Algorithm STEP 1 − Import the package fmt STEP 2 − Start function main() STEP 3 − Declare and initialize the variables and assign value to them. STEP 4 − Initialize a variable to store the number of rows that star pattern should print. STEP 5 ... Read More
522 Views
An enum combines related constants into a single type. Enums are a strong feature with many applications. However, compared to the majority of other programming languages, they are implemented very differently in Go. In this article, we'll see how to use a predeclared identifiable iota to implement enums in Golang. IOTA − Iota is an identifier that is used with constants and can make auto-increment number-based constant definitions simpler. The keyword "iota" stands for an integer constant that begins at zero. Implementing Iota package main import "fmt" const ( c0 = iota + 1 ... Read More
2K+ Views
In this tutorial, we will see to write a go language program to search the largest element in an array. an array is a variable that is used to store elements at contiguous memory locations. We can find the largest element of an array by either using a separate function or by using for loop and if conditions in the main() function. Finding the Largest Element in an Array in Main Function() The following code illustrates how we can search and find the largest element present in an array. Algorithm STEP 1 − Import the fmt package that allows us ... Read More
720 Views
In this tutorial, we will see to write a go language program to rotate an array. We will write two programs for this. One to rotate the array to left and another to rotate it to right. Algorithm STEP 1 − Import the fmt package that allows us to print anything on the screen. STEP 2 − Create a function named rotateLeft() which returns the final array after rotating it. STEP 3 − This function uses a for loop to iterate over the array and calls rotateLeftByOne() function in each iteration. STEP 4 − This function takes the array as ... Read More