Found 1082 Articles for Go Programming

Golang Program to get the remainder of float numbers using library function

Akhil Sharma
Updated on 25-Oct-2022 12:58:41

397 Views

In this article we will discuss about how to get the remainder of float numbers using library function in Go language. In programming, a float is a number that has a decimal point in it. For example: 0.2, 5.89, 20.79, etc. Remainder: Remainder in division is defined as the result left after the division process is over. For example, if 4 is the dividend and 2 is the divisor then after dividing 4 with 2 the remainder will be 0. Similarly on dividing 4 with 3 the remainder will be 1. To get the remainder of floating values we can ... Read More

Golang Program to get the Quotient and remainder using library function

Akhil Sharma
Updated on 25-Oct-2022 12:48:33

474 Views

In this article we will discuss about how to get the quotient and remainder in GO language using library function. Syntax func Div(a, b, c uint) (q, r uint) func Remainder(q, r float64) float64 The div() function accepts three arguments as unsigned integers and returns the quotient and remainder respectively after computing the division process. The remainder() function accepts two arguments as 64-bit float values and returns the remainder after performing the division process in the same format. The source code to get the quotient and remainder of division using library functions is compiled and executed below. Finding The ... Read More

Golang Program to Find the Sum of N Numbers using Recursion

Akhil Sharma
Updated on 25-Oct-2022 12:31:17

1K+ Views

In this tutorial, we are going to learn how to find the sum of N Numbers using Recursion in Golang programming language. A Recursion is where a function calls itself by direct or indirect means. Every recursive function has a base case or base condition which is the final executable statement in recursion and halts further calls. Below are two examples showing the two different type of recursion: direct and indirect. Find the Sum of N Numbers by Direct Recursion Method Syntax Syntax for direct recursion func recursion() { recursion() } func main() { ... Read More

Golang Program to Find the Sum of Natural Numbers using Recursion

Akhil Sharma
Updated on 25-Oct-2022 12:21:25

245 Views

In this tutorial, we are going to learn how to find the sum of Natural Numbers using Recursion in Golang. A Recursion is where a function calls itself by direct or indirect means. Every recursive function has a base case or base condition which is the final executable statement in recursion and halts further calls. Below are two examples showing the two different type of recursion: direct and indirect. Find the Sum of Natural numbers by Direct Recursion Method Syntax func recursion() { recursion() } func main() { recursion(); } Algorithm Step ... Read More

Golang Program to Reverse a Sentence using Recursion

Akhil Sharma
Updated on 25-Oct-2022 12:10:12

479 Views

In this tutorial, we will learn how to reverse a sentence using recursion in Go Programming Language. A Recursion is where a function calls itself by direct or indirect means. Every recursive function has a base case or base condition which is the final executable statement in recursion and halts further calls. The recursion continues until some condition is met to prevent it. Below are two examples showing the two different type of recursion: direct and indirect. Reverse a Sentence using Recursion by using Direct Recursion Method Syntax Func recursion() { recursion(); /* function calls itself */ ... Read More

Golang Program to make a Simple Calculator using Switch Case

Akhil Sharma
Updated on 28-Oct-2022 07:58:28

4K+ Views

In this tutorial we will see how to make a simple calculator using switch case statements in Go programming language. The switch statement will assess an expression, comparing the expression's value against a series of case conditions given in a series and executes the statement after the first condition with a matching value, until a break is encountered. Golang Basic switch case with default A switch statement runs the first case equal to the choice entered. The cases are evaluated in an order and it stops when a case succeeds. If no case (choice entered) matches, it is a ... Read More

Golang Program to Create a Function without Argument and Without a Return Value

Akhil Sharma
Updated on 25-Oct-2022 11:41:08

1K+ Views

In this tutorial we will learn how to create a function without argument and without a return value in Go Programming Language. When a function has no arguments, it does not receive any data from the calling function. Similarly when it does not return any value, the calling function does not receive any data from the called function. So there is no data transfer between calling and called function. Add two Numbers Algorithm Step 1 − Import the package fmt package Step 2 − Start function main () Step 3 − Calling the function add () Step 4 − ... Read More

Golang Program to Find G.C.D Using Recursion

Akhil Sharma
Updated on 25-Oct-2022 11:34:00

830 Views

In this tutorial we will discuss how to write a Golang program to find the greatest common divisor GCD using recursion. The greatest common divisor (GCD) of two or more numbers is the greatest common factor number that divides them, exactly. It is also called the highest common factor (HCF). For example, the greatest common factor of 15 and 10 is 5, since both the numbers can be divided by 5. 15/5 = 3 10/5 = 2 Algorithm Step 1 − Import the package fmt Step 2 − Start function main() Step 3 − We will use an ... Read More

Golang Program to convert a number into a rational number

Akhil Sharma
Updated on 09-Dec-2022 05:54:57

359 Views

In this tutorial we will see how to convert a number into a rational number using Go programming language. A rational number is a type of real number, which is in the form of p/q where q is not equal to zero. Any fraction with non-zero denominators is a rational number. Some of the examples of rational numbers are 1/2, 1/5, 3/4, and so on. Syntax funcNewRat(a, b int64) *Rat NewRat creates a new Rat with numerator a and denominator b Syntax for Scanln: Func Scanln(a…interface{}) (n int, err error) Package math/big implements arbitrary-precision arithmetic (big numbers). ... Read More

Golang Program to extract the last two digits from the given year

Akhil Sharma
Updated on 30-Nov-2022 13:58:11

1K+ Views

In this tutorial we will discuss how to write a GO program to extract the last two digits of a given year. This program takes any year as input and prints its last two digits. You need to extract the last two digits from a given year, by using the modulus operation. Modulus Operation The % operator is the modulus operator, which returns the remainder rather than the quotient after division. This is useful for finding numbers that are multiples of the same number. As the name suggests where there is an execution to be operated required to deal with ... Read More

Advertisements