Go Programming Articles

Page 73 of 86

Golang Program to convert a number into a rational number

Akhil Sharma
Akhil Sharma
Updated on 09-Dec-2022 606 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
Akhil Sharma
Updated on 30-Nov-2022 2K+ 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

How to Sort Elements in Lexicographical Order (Dictionary Order) in Golang?

Aman Sharma
Aman Sharma
Updated on 29-Nov-2022 2K+ Views

In this tutorial, we will write the Golang program to sort the elements in lexicographical order. The tutorial will include three different ways to do this thing. To do the sorting we need to compare two strings and for that, we will use the < operator it will return a boolean value. If the value on the left side is greater than the right side value lexicographically then it will return false else true. For example, Tutorial < Point - The operator will return true. C++ < Golang - The operator will return false. Algorithm Step 1 − Create and ...

Read More

How To Perform nCr (r-combinations) in Golang?

Aman Sharma
Aman Sharma
Updated on 29-Nov-2022 709 Views

In this tutorial, we will perform nCr(r-combinations) in the Golang programming language. The use case of nCr(r-combinations) is to find the total number of possible arrangements where the order does not matter. In other words, we are selecting the r items from n items where the order does not matter. This tutorial will include two ways to find this in the Golang programming language. Explanation For example, for n =5 and r = 3 nCr = n! / ( r! * ( n - r )! ) = 5! / ( 3! * 2! ) = 120 / ...

Read More

How to find the Surface area and Volume of Cuboid in Golang?

Aman Sharma
Aman Sharma
Updated on 29-Nov-2022 269 Views

In this tutorial, we will see the Golang program to find the Surface Area and Volume of a Cuboid. The area is the total space covered by any closed figure. The volume is the capacity to hold something inside the vessel. Formula l - length of a Cuboid h - the height of a Cuboid w - width of a Cuboid. Surface Area of Cuboid - 2*l*w + 2*w*h + 2*l*h For example, the length of a Cuboid is 10 cm, the height is 5 cm and, the width is 8 cm so the Surface Area of a ...

Read More

How to find the Arc Tangent of a given value in Golang?

Aman Sharma
Aman Sharma
Updated on 29-Nov-2022 254 Views

In this tutorial, we will learn how to find the Arc Tangent of a given value in the Golang programming Language. Golang language has many packages with predefined functions that the developer can use without writing the complete logic To perform the mathematical operations and logic we have a math package in Golang. We will use this package only to find the Arc Tangent of a given value. We will also see how to import the package and also how to call a function this package consists of by writing a Golang code. Arc Tangent Definition Arc Tangent is a ...

Read More

How to find the Arc Sine of a given value in Golang?

Aman Sharma
Aman Sharma
Updated on 29-Nov-2022 251 Views

In this tutorial, we will learn how to find the Arc Sine of a given value in the Golang programming Language. Golang language has many packages with predefined functions that the developer can use without writing the complete logic. To perform the mathematical operations and logic we have a math package in Golang. We will use this package only to find the Arc Sine of a given value. We will also see how to import the package and also how to call a function this package consists of by writing a Golang code. Arc Sine Definition Arc Sine is ...

Read More

How to Find all Roots of a Quadratic Equation in Golang?

Aman Sharma
Aman Sharma
Updated on 29-Nov-2022 1K+ Views

In this tutorial, we will find the root of a quadratic equation using the Golang programming language. The tutorial includes two different ways of programming to find out the roots of the quadratic equation. Explanation The equation with power two is called a quadratic equation. The standard equation of the quadratic equation is − $$\mathrm{a\:x\:^{\wedge}\:2\:+\:b\:x\:+\:c\:=\:0}$$ In the above equation a, b, and c are coefficients where a cannot be zero. To find the nature of the roots of the quadratic equation i.e they are real or imaginary first we need to find the discriminant of the equation using the ...

Read More

Golang Program to Print Spiral Pattern of Numbers

Akhil Sharma
Akhil Sharma
Updated on 22-Nov-2022 481 Views

In this tutorial, we will learn how to print spiral pattern of Numbers using Go programming language. A Spiral pattern of numbers is used to print numbers in spiral pattern on the screen. In this program we will create an array of size n, store numbers in it and use the array to create a matrix in a spiral format. Syntax for initialization; condition; update { statement(s) } func make([]T, len, cap) []T make() function is used to allocate memory of heap for some variables. For eg we can use make() function to allocate memory for ...

Read More

Golang Program to Print Reverse Pyramid Star Pattern

Akhil Sharma
Akhil Sharma
Updated on 22-Nov-2022 736 Views

In this tutorial we will write a Go-lang code to print Reverse pyramid star pattern. We will depict how you can print the reverse pyramid star pattern. ********* ******* ***** *** * How to print a Reverse Pyramid star pattern? A pattern is shown above, and in the pattern, you can clearly see that 2 stars is decreasing with increase in each row. If the total rows are 5, the pattern goes like ...

Read More
Showing 721–730 of 852 articles
« Prev 1 71 72 73 74 75 86 Next »
Advertisements