Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Articles by Akhil Sharma
Page 47 of 51
Golang Program to Calculate Standard Deviation
In this tutorial, we will write a go language code to calculate the standard deviation. The standard deviation is a statistic that expresses how much variance or dispersion there is in a group of numbers. It is calculated as the square root of the mean. Find the Standard Deviation Using External Functions In this example, we will write a go language program to calculate the standard deviation using user-defined functions. Algorithm to the Above Program Step 1 − Import the fmt, math, and start. Step 2 − Create the standardDeviation() function. This function uses a for loop to intend ...
Read MoreGolang Program To Add Two Matrices
In this tutorial, we will write a go language program to add two matrices. A matrix is a collection of numbers that are arranged in rows and columns, which is a two-dimensional array. Go Language Program To Add Two Matrices Let us now look at a go language program to add two matrices using loops. Algorithm to the Above Program Step 1 − Import the fmt package. Step 2 − Now we need to start the main() function. Step 3 − Then we are creating two matrices named matrixA and matrixB and store values in them. Step 4 − Print ...
Read MoreGolang Program For Array Rotation
Introduction In this tutorial, we will see to write a go language program to rotate an array. We will write two programs for this. One to rotate the array to left and another to rotate it to right. Golang Program to Rotate an Array to Left The following code illustrates how we can rotate an array to left using a user defined function. Algorithm to the above Program Step 1 − Import the fmt package that allows us to print anything on the screen. Step 2 − Create a function named rotateLeft() which returns the final array after rotating it. ...
Read MoreGolang Program to get the denominator from a rational number
In this article, we will discuss how to get the denominator from a rational number. Rational numbers − In mathematics, rational numbers are defined as numbers that can be expressed in the form of a/b where a and b are integer values. For example- 1/3, 5/8 etc. Note that the denominator of a rational number can never be zero. Syntax func NewRat(a, b int64) *Rat func (x *Rat) Denom() *Int NewRat() function takes two integer numbers as input arguments and returns a rational number in the form of a/b. here a is the numerator and b is the denominator ...
Read MoreGolang Program to Convert Character to String
In this article, we are going to learn about how to convert characters to string go programming language. Chars − Go language does not have a char data type on the contrary characters in go language are represented by rune data type. Rune represents a character value that is encoded in UTF-8 format. The size of the runes is 32-bits. Strings − String data type is used to store a sequence of characters. it can be in the form of literals or alphabets. The size of the string variable is 1 byte or 8 bits. There are two approaches to ...
Read MoreGolang Program to Create an Interface
In this article, we are going to learn about how to create an interface using golang programming INTERFACE − In the go language, an interface is a custom type that is used to specify one or more method signatures. An interface is abstract i.e. we cannot create an instance of the interface but we can create a variable to the interface type and assign this variable to the struct or class that has methods needed by the interface. Syntax type interface_name interface { // method signatures } Example 1 To define an interface first we need ...
Read MoreGolang Program to Create a Class and Object
In this article we are going to learn how to create class and object. Structs − Go language does not have classes. To create an object in the go programming language we can specify structs and store key-value pairs in it. A struct is a user-defined data type that is used to store data together. The values so stored may have the same or different data type. Syntax The syntax to define a structure is as follows − type name_of_struct struct { name_1 type_1 name_2 type_2 name_3 type_3 ...
Read MoreGolang Program to convert a number into a rational number
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 MoreGolang Program to extract the last two digits from the given year
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 MoreGolang Program to Print Spiral Pattern of Numbers
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