Found 1082 Articles for Go Programming

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

Aman Sharma
Updated on 29-Nov-2022 07:27:32

685 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
Updated on 22-Nov-2022 13:06:30

309 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
Updated on 22-Nov-2022 13:02:15

487 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

Golang Program to Print Pyramid Star Pattern

Akhil Sharma
Updated on 22-Nov-2022 12:58:40

634 Views

In this tutorial we will write a Go language code to print pyramid star pattern. We will depict how you can print the pyramid star pattern. * * * * * * * * * * * * * * * * * * * * * * * * * How to print a Pyramid star pattern? A pattern is shown above, and in the pattern, you can clearly see that 2 stars is increasing with increase in ... Read More

Golang Program to convert int type variables to String

Akhil Sharma
Updated on 22-Nov-2022 12:49:27

16K+ Views

In this tutorial we will learn how to convert int type variables to string variables using Golang programming language. A string is defined as the sequence of one or more characters (letters, numbers, or symbols). Computer applications frequently use strings as a data type thus, there is a need to convert strings to numbers or numbers to strings at manny places specially when we are using data entered by the user. Syntax func Itoa(x int) string Itoa() function in go programming language is used to get the string representation of any integer value here it is depicted by ... Read More

Golang Program to convert double type variables to string

Akhil Sharma
Updated on 22-Nov-2022 12:21:36

636 Views

In this tutorial we will learn how to convert double(float64) type variables to string variables using Golang programming language. Double stands for double precision. In programming languages, a double data-type is used to handle decimal numbers more precisely i.e. using double data type we can store more number of digits after a decimal point with accuracy. String data type is used to store a sequence of characters. It can be in the form of literals or alphabets. The size of string variable is 1 byte or 8 bits. EXAMPLE 1: GO LANGUAGE CODE TO CONVERT DOUBLE TYPE ... Read More

Golang Program to convert double type variables to int

Akhil Sharma
Updated on 22-Nov-2022 12:16:02

2K+ Views

In this tutorial we will learn how to convert double type variables to integer variables using Golang programming language. Double stands for double precision. In programming languages, a double data-type is used to handle decimal numbers more precisely i.e. using double data type we can store more number of digits after a decimal point with accuracy EXAMPLE 1: GO LANGUAGE CODE TO CONVERT DOUBLE TYPE VARIABLES TO INT: Syntax fmt.Println(int(b)) Int(x) To convert a float type input ... Read More

Golang program to find the area of a rectangle

Saumya Srivastava
Updated on 21-Nov-2022 06:56:16

499 Views

This tutorial will discuss how to find the area of a rectangle in Golang programming using two methods − Area of the rectangle using length and breadth Area of the rectangle using diagonal and breadth Rectangle A rectangle is a two-dimensional shape that has four sides. The opposite sides of a rectangle are equal and all the angles of a rectangle are at 90°. Another property of a rectangle is that its opposite sides are parallel to each other. Area of a rectangle The total space enclosed within the boundary of the rectangle is known as the area ... Read More

Golang program to calculate the volume of a cube

Saumya Srivastava
Updated on 21-Nov-2022 06:51:26

226 Views

In this tutorial, we will be discussing the approach to finding the volume of a cube in Golang programming using the sides of the cube. But before writing the code for this, let’s briefly discuss the cube and its volume. Cube A cube is a three-dimensional figure that has six square faces. All six faces of the cube are in the shape of a square. Its length, breadth, and height are equal. Dice is a common example of a cube. Volume of a cube The total three-dimensional space occupied by the cube is known as the volume of ... Read More

Golang program to calculate the volume and area of the Cylinder

Saumya Srivastava
Updated on 21-Nov-2022 06:38:05

173 Views

In this tutorial, we will be discussing the approach to calculate the volume and area of a cylinder in Golang programming using its height and radius. But before writing the code for this, let’s briefly discuss the cylinder and its volume and area. Cylinder A cylinder is a three-dimensional figure whose base has a circular shape. The distance between the two bases is known as the cylinder’s height ‘h’ and the radius of the base is denoted by ‘r’. A cold drink can is a good example of a cylinder. Volume of a cylinder The capacity ... Read More

Advertisements