Found 1082 Articles for Go Programming

Golang program to calculate the volume and area of a Sphere

Saumya Srivastava
Updated on 21-Nov-2022 06:33:21

164 Views

In this tutorial, we will be discussing the approach to calculate the volume and area of a sphere using its radius in Golang programming. But before writing the code for this, let’s briefly discuss the sphere and its volume and area. Sphere A sphere is a three-dimensional figure whose all points are equidistant from the center. It has no edges and no faces. The radius of the sphere is denoted by ‘r’. A ball is a good example of a sphere. Volume of a sphere The capacity or amount of space a sphere occupies is termed ... Read More

Golang program to calculate the volume and area of a Cone

Saumya Srivastava
Updated on 21-Nov-2022 06:29:08

209 Views

In this tutorial, we will be discussing the approach to calculate the volume and area of a cone using its height and radius in Golang programming. But before writing the code for this, let’s briefly discuss the cone and its volume and area. Cone A cone is a three-dimensional figure that is pointed at the top and its base is flat and curved. The height of the cone is denoted by ‘h’ and the radius of the flat curved surface is denoted by ‘r’. An ice cream cone is a good example of a cone. $$\mathrm{where\: length \, ... Read More

Golang program to calculate the sum of all odd numbers up to N

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

388 Views

In this tutorial, we will be discussing the program to find the sum of all odd numbers up to ‘N’ in Golang programming. But before writing the code for this, let’s have a brief discussion on odd numbers. Odd Numbers An odd number is a number that is not completely divisible by 2 and its remainder is always 1 when the number is divided by 2. A simple way to check whether a number is an odd number or not is to check its last digit. If the last digit is 1, 3, 5, 7, or 9, then the number ... Read More

Golang program to calculate the sum of all even numbers

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

332 Views

In this tutorial, we will be discussing the program to find the sum of all even numbers in Golang programming. But before writing the code for this, let’s briefly discuss even numbers. Even Numbers An even number is a number that is completely divisible by 2 and its remainder is always 0. A simple way to check whether a number is an even number or not is to check its last digit. If the last digit is 0, 2, 4, 6, or 8, then the number is said to be an even number. Iterate through the first n even numbers ... Read More

Golang program to calculate the area of a cube

Saumya Srivastava
Updated on 21-Nov-2022 06:08:19

219 Views

In this tutorial, we will be discussing the approach to finding the surface area 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 area. 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. Area of a cube The total area enclosed by all six faces of the cube is known as the ... Read More

Golang Program to convert Hexadecimal to Decimal

Akhil Sharma
Updated on 16-Nov-2022 06:59:59

7K+ Views

In this article we are going to understand how to covert Hexadecimal to Decimal number using Golang Program. Hexadecimal Number Vs Decimal Numbers Any number contains 16 digits in it, it is based on base 16, which means hexadecimal numbers contains decimal number from 0 to 9 and extra 6 Alphabets. A−F. In go language all the hexadecimal numbers start with 0x or 0X. For example, 0x16F is a hexadecimal number Decimal numbers are the numbers which have base 10, which means each digit of a number can have an integer value ranging from 0 to depending on its position. ... Read More

Golang Program To Print X Star Pattern

Akhil Sharma
Updated on 16-Nov-2022 06:48:53

697 Views

In this tutorial, we will learn how to print X star pattern using Go programming language. Syntax for initialization; condition; update { statement(s) } Example: Go Program Code to Print x Star Pattern Using a Single Function Algorithm Step 1 − Import the package fmt and strconv package. Step 2 − Start function main (). Step 3 − Declare and initialize the variables. Step 4 − Use of for loop with condition and incrementor. Step 5 − Print the result using fmt.Println (). Example // GOLANG PROGRAM TO PRINT X STAR PATTERN package main ... Read More

Golang Program To Print Star Pascals Triangle

Akhil Sharma
Updated on 16-Nov-2022 06:36:55

452 Views

In this tutorial, we will learn how to print star Pascal’s triangle using Go programming language Example 1: Golang Code To Print Star Pascal Triangle Using Strconv Package Syntax func Itoa(x int) string Itoa() function takes in an integer parameter and returns the string representation of x when the base is 10 Algorithm Step 1 − Import the package fmt and strconv package. Step 2 − Start function main (). Step 3 − Declare and initialize the variables. Step 4 − Use of for loop with condition and incrementor. Step 5 − Print the result using fmt.Println (). ... Read More

Golang Program To Print Square Star Pattern

Akhil Sharma
Updated on 16-Nov-2022 06:32:51

455 Views

In this tutorial, we will learn how to print square star pattern using Go programming language. Syntax NESTED FOR LOOP: for [condition | ( init; condition; increment ) | Range] { for [condition | ( init; condition; increment ) | Range] { statement(s); } statement(s); } Example: Golang Program Code To Print Square Star Pattern Using A Single Function Algorithm Step 1 − Import the package fmt. Step 2 − Start the function main (). Step 3 − Declare and initialize the variables. ... Read More

Golang Program To Print Mirror Upper Star Triangle Pattern

Akhil Sharma
Updated on 16-Nov-2022 06:28:15

187 Views

In this tutorial, we will learn how to print downward triangle pattern using Go programming language. Syntax for initialization; condition; update { statement(s) } In the code, we use the for loop to repeat a block of code until the specified condition is met. Example: Golang Program to Print Download Triangle Star Pattern Using One Single Function Algorithm Step 1 − Import the package fmt. Step 2 − Start the function main (). Step 3 − Declare and initialize the variables. Step 4 − Use of for loop with condition and incrementor. Step 5 − ... Read More

Advertisements