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 Aman Sharma
Page 5 of 6
How to print the ASCII values in Golang?
In this tutorial, we are going to learn how to find and print the ASCII value of any character or symbol in Golang. The ASCII stands for American Standard Code for Information Exchange which is a way to represent the characters, and symbols in numeric form. Printing the ASCII value using specifier Algorithm STEP 1 − Declaring the variable of string type STEP 2 − Initializing the variable. STEP 3 − Running the for loop which is printing the ASCII value for each element in the string. Example 1 In this example, we are going to print the ASCII ...
Read MoreHow to find the Area of a Circle in Golang?
In this tutorial, we are going to see the Golang program to find the Area of a Circle. The area is the total space covered by any closed figure. Formula Area of Circle - 22 / 7 * r * r r - radius of a Circle For example, the radius of a Circle is 10 cm so the Area of a Circle is − Area = 22 / 7 * 10 * 10 = 4.2857142857143 Finding the Area of a circle within the function Algorithm STEP 1 − Declaring the variables for the ...
Read MoreHow to find the Perimeter of a Rectangle in Golang?
In this tutorial, we are going to see the Golang program to find the perimeter of a rectangle. Perimeter is the total length of the boundary of any closed figure Formula Perimeter of rectangle - 2 * ( L + B ) L - Length of a rectangle B - Breadth of a rectangle For example, the length of a rectangle is 100 cm and the breadth is 50 cm so the Perimeter of a rectangle is − Perimeter = 2 * (100 + 50) cm = 2 * (150) cm = 300 ...
Read MoreHow to Calculate Compound Interest using Golang code?
In this tutorial, we are going to see the program for calculating compound interest in Golang. It is a method of finding the accurate interest on loans in the banking and finance sector using factors like principal amount, rate per annum, and time. Due to more accuracy, the rates are higher than the simple interest. Formula compound_Interest = P * ( 1 + R / 100) ^ T P = Principal amount R = Rate per annum T = Time For example, suppose the principal amount is 1000, the rate of interest is 4 and the interval is 2 ...
Read MoreHow to find the Factorial of a number in Golang?
In this tutorial, we are going to write and explain the code to find the factorial of a number in Golang. The factorial is the multiplication of the number with all the numbers less than it. In this tutorial, we will see two ways to find the factorial in Golang. One is by creating a recursive function. Second, by using the for a loop. For example, the factorial of 5 is: 5! = 5 * 4 * 3 * 2 * 1 = 120 A recursive approach to finding the factorial of a number Algorithm STEP 1 − ...
Read MoreHow to check whether the input number is a Neon Number in Golang?
In this tutorial, we are going to write and explain the code to check whether the given number is a neon number or not. The Neon number is a number that is equal to the sum of all the digits of its square. For example, 9 is a neon number as shown below The square of 9 is: 9 * 9 = 81 The sum of each digit of the square i.e 81 is 9 and the number is also 9 so 9 is a Neon number. Algorithm STEP 1 − First we are declaring the numbers between ...
Read MoreHow to Check Armstrong Number between Two Integers in Golang?
In this tutorial, we are going to write and explain the code for finding the Armstrong number between two integers. The Armstrong number is a number whose sum of the cube of all the digits in the number is equal to the number itself. For example, 153 is a number as shown below 153 = 1^3 + 5^3 + 3^3 = 1 + 125 + 27 = 153 Algorithm STEP 1 − First we are declaring the numbers between which we have to find the Armstrong Numbers. STEP 2 − Now, we ...
Read MoreHow to Display all Prime Numbers from 1 to N in Golang?
In this tutorial, we will learn how to print the prime numbers from 1 to N where N the value of N will be as an input from the user. Just a short brief about Prime numbers is that the Prime numbers are something which can be only divisible by 1 or itself. In this tutorial, we are going to discuss two approaches one which will take O(N^2) of time and the other will take O(N*log(logN)). Method 1 Time Complexity: O(N^2) Space Complexity: O(1) Algorithm STEP 1 − Declaring the number N of type int32 STEP 2 − Take ...
Read MoreHow to get Input from the User in Golang?
In this tutorial, we will see how to get the input from the user in Golang. Golang has a library that consists of an input/output function which helps in printing and taking the output. The function to take the input is Scanln(). Algorithm For Taking Integer Input with User STEP 1 − We are importing the fmt package that has the input/output functions. STEP 2 − We are declaring a variable after that we are printing the lines to ask the user to give the input STEP 3 − Then using fmt.Scanln() we are taking the input and storing ...
Read MoreHow to Swap Two Numbers in Golang?
In this tutorial, we will discuss swapping two numbers in Golang. We will cover two approaches: first swapping two numbers within the function and second creating a different function. Swapping two numbers within the function Algorithm STEP 1 − Defining the variables that we want to Swap. STEP 2 − Initializing the variables. STEP 3 − Swapping the two variables within the function. STEP 4 − Print the variables after swapping. Example package main // fmt package provides the function to print anything import "fmt" func main() { // define the variables we ...
Read More