Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Programming Articles - Page 559 of 3363
935 Views
In this tutorial, we will learn how to calculate the power using recursion technique in Go programming language. Power can be defined as a number being multiplied by itself a specific number of times. Exponent can be defined to the number of times a number is used in a multiplication. Powers and exponents are important tools to rewrite long multiplication problems in mathematics, especially in algebra. Example: 24 = 2 × 2 × 2 × 2 = 16, where 2 is the base and 4 is the exponent. A Recursion is where a function calls itself by direct or indirect ... Read More
1K+ Views
In this tutorial we will write a Go-lang code to print a right Triangle star pattern. We will depict how you can print the star pattern in go language. * * * * * * * * * * How to print a star pattern? A right triangle star pattern is shown above, and in that pattern, you can see that stars are increasing with the increase in the number of rows. The pattern goes like this 1 star in first row, 2 stars in second row, and goes on. For loop for [condition | ( init; condition; increment) ... Read More
534 Views
In this tutorial we will write a Go-lang code to print a Left Triangle star pattern. We will depict how you can print the star pattern in go language. * * * * * * * * * * How to print a star pattern? A left triangle star pattern is shown above, and in this pattern, you can see that stars are increasing with the increase in the number of rows. The pattern goes like this 1 star in first row, 2 stars in second row, and goes on. We will be ... Read More
404 Views
In this tutorial, we will learn how to print half diamond star pattern using Go programming language. Syntax for initialization; condition; update { statement(s) } To use a for loop in go lang we first need to initialize a variable then specify the condition of the loop i.e when should the loop end then we need to increment or decrement the variable followed by the lines of codes that should get executed. Example 1: Golang Program Code to print Half Diamond Star Pattern Using a Single Function Approach The goal is to divide the pattern into ... Read More
707 Views
In this article we will discuss about how to get real part from a complex number in Go language. A complex number in mathematics is a number that can be expressed in the form of a + ib where i is called iota. The value of iota is $\mathrm{\sqrt{-1}}$ and a and b are real numbers. The first part i.e ‘a’ is called real part of complex number and the part after iota i.e ’b’ is called imaginary part of complex number. Syntax func real(number complex128) float64 The real() function is used to get the get the real part ... Read More
820 Views
In this article we will discuss about how to get the magnitude of a number in Go language. Magnitude of a quantity is defined as its numeric value. Magnitude of a number is always positive. In this article we will discuss about different methods by which we can obtain the magnitude of any number. Syntax func Abs(number float64) float64 Abs() is a method defined in math library. This method accepts a 64 bit float number as an argument and return the absolute value of it excluding the sign. The source code to the above stated problem is compiled and ... Read More
437 Views
In this article we will discuss about how to display prime numbers between two intervals using functions in Go language. Syntax func Sieve(n int) []int func IsPrime(n int) bool If else conditionals in GO language: If condition { // code to be executed } else { // code to be executed } For loop as a while loop in GO language: for condition { // code to be executed // increment or decrement the count variable. } Sieve() function defined in primes package accepts ... Read More
798 Views
In this tutorial we will learn how to create Complex numbers from given imaginary parts in Go programming language. A complex number is a basic data type of GoLang and is a combination of the real and imaginary part, where both parts of the complex number will be float type in golang. Complex Number = Real Number + Imaginary Number The function complex()in Go programming language is a built-in function that is used to construct a complex number from two floating-point values. The real and imaginary parts of the complex value must be of the same size and the return ... Read More
2K+ Views
In this tutorial, we will learn how to convert string variables to double in Go programming language. String is a data type which is used to store characters or alphabets. Strings have a size of 1 byte or 8 bits. Whereas double is a data type which is used to store double precision floating point numbers. The size of double is 64 bits or 8 bytes. Program to Convert String type Variable to Double Using ParseFloat() Method Syntax func ParseFloat (s string, bitsize int) (float 64, error) ParseFloat() function is used to convert strings to float type values. This ... Read More
11K+ Views
In this tutorial, we will learn how to convert string type variables into int in Go programming language. For this task various types of string conversions are needed, to perform the conversions “strconv” package is imported in the go language program, Strings can be transformed into integer values using the ParseInt function. It decodes a string in the specified base (0, 2 to 36) and bit size (0, 64), and then it returns the equivalent result. Convert String Type Variable Into Int Syntax func ParseInt(s string, radix/base int, bitSize int) (i int64, err error) ParseInt() function is used to ... Read More