Create a Function with Arguments and Return Value in Golang

Aman Sharma
Updated on 11-Jan-2023 17:26:30

842 Views

This tutorial will teach us how to create a function with arguments and a return value. This tutorial involves a gist about the function, and syntax for the function with an argument and a return type in Golang, then last we will see two different examples of a function with arguments and with a return type. In one example we will return the sum of two numbers and in the other one, we will return the area of the circle. Functions in the Programming language. Let us first see what function is. The function is a subset of a program ... Read More

Create Function without Argument but Return Value in Golang

Aman Sharma
Updated on 11-Jan-2023 17:21:41

2K+ Views

This tutorial will teach us how to create a function without arguments and with a return value. This tutorial involves a gist about the function, and syntax for the function without an argument and with a return type in Golang, then last we will see two different examples of a function without arguments and with a return type. In both examples, we are going to create two functions which are returning a string whenever called. Function without argument and with a return type. SyntaxNow we will see the syntax and explanation for the function without an argument and with a ... Read More

Create a Simple Recursive Function in Golang

Aman Sharma
Updated on 11-Jan-2023 17:19:13

321 Views

In this tutorial, we are going to see how we can write a simple recursive function Golang with the help of an algorithm and, examples. In the first example, we will print the number from 1 to N in ascending order similarly in the other example we are going to print the number from 1 to N in descending order. In terms of programming, a function is a recursive function if we are calling the function in the same function and have a base condition. Whenever the base condition is satisfied the calling of the function is stopped and we ... Read More

Find GCD of Two Numbers Using Recursion in Golang

Aman Sharma
Updated on 11-Jan-2023 17:16:17

345 Views

In this tutorial, we will see how to find the Greatest common divisor of two numbers using the Golang language using recursion. We will see two ways to find the GCD of two numbers recursively. First will take more time where we are reducing the minimum of both numbers by 1 and then check if both the numbers are divisible by the min number or not. The second approach will take less time where we are subtracting the larger number from the smaller number until both numbers become equal. Algorithm Step 1 - Declaring the variables to store the ... Read More

Return Multiple Values from Function in Golang

Aman Sharma
Updated on 11-Jan-2023 17:13:58

2K+ Views

In this tutorial, we are going to see how we can return multiple values from the function in Golang with the help of an algorithm and examples. Like other programming languages like python, Golang also supports returning multiple values from a function. In the first, example we are going to pass two numbers in the function and return the smaller and then greater number together. In the second example we are passing two numbers and returning the addition, subtraction, multiplication, and division at once. Syntax Func functionName(arguments) (returnType1, returnType2, …) { // logic ... Read More

Reverse a Given Number Using Recursion in Go

Aman Sharma
Updated on 11-Jan-2023 17:10:40

723 Views

In this tutorial, we are going to learn how we can find the reverse of the given number in the Golang programming language. The recursive function is more suitable if we want to modify the function that is not possible with a For loop. In this article, we are going to achieve this by using recursion. Explanation Iteration 1: Number = 54678 Reverse of number = 0 Reverse of number = Reverse of number * 10 + Number % 10 = 0 + 54678 % 10 = 0 + 8 = ... Read More

Find LCM of Two Numbers Using Recursion in Golang

Aman Sharma
Updated on 11-Jan-2023 17:02:33

736 Views

In this tutorial, we are going to find the Least common multiple of two numbers in Golang using recursion. To find the LCM recursively we are going to use the relation of LCM with the Greatest common divisible i.e GCD of both the numbers. LCM stands for least common multiple is the smallest number divisible by two numbers. For example, Suppose the two numbers are 10 and 4. The smallest number that is divisible by both numbers evenly is 20. Finding LCM Using the Relation between LCM and GCD In this example, we are going to find the LCM using ... Read More

Check If Character Is in the Alphabet in Golang

Aman Sharma
Updated on 11-Jan-2023 16:54:04

1K+ Views

In this tutorial, we will learn how to check whether the character is an alphabet or not. This tutorial includes two ways to achieve this − First, using the built-in function isLetter() present in the fmt library will reduce the line of codes. Another way is to use the concept of ASCII values as every character has a unique ASCII value using which we can find out whether the current character is an alphabet or not. The ranges of uppercase and lowercase alphabets are as follows − uppercase alphabets – 65 to 90 lowercase alphabets – 97 to 122 If ... Read More

Difference Between ZIP and RAR

Kiran Kumar Panigrahi
Updated on 11-Jan-2023 16:07:31

3K+ Views

There are various types of file formats available in computer file systems. ZIP and RAR are types of archive file formats that are used to store different types of files and folders in a single container. However, ZIP and RAR file formats are quite different from each other. The most fundamental difference between ZIP and RAR is that ZIP is a standard archive file format that can be enabled in any operating system, whereas RAR is an archive file format that requires a third-party tool named WinRAR for its processing. Read this tutorial to learn more about the ZIP and ... Read More

Difference Between SSD and HDD

Kiran Kumar Panigrahi
Updated on 11-Jan-2023 15:55:41

2K+ Views

In computer systems, different types of memory devices are used to store data permanently. Both SSD and HDD are such storage devices. SSD and HDD are the most commonly used types of secondary memories. HDD is a traditional storage device, while SSD is a modern storage device. SSD and HDD are quite different from each other. The most fundamental difference between SSD and HDD is that SSD (Solid State Drive) is a storage device that stores data in integrated circuits, whereas HDD (Hard Disc Drive) is a device that stores data magnetically. There are several other differences between SSD and ... Read More

Advertisements