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 517 of 3363
678 Views
In this tutorial, we will write a go language program to find the sum of diagonal elements of a matrix. Compute the Sum of Diagonals of a Matrix In this example, we will find the sum of left diagonal elements of a 3 x 3 matrix using external function. Algorithm Step 1 − Import the fmt package. Step 2 − Create a function to find the sum of the given matrix. Step 3 − In this function initialize an integer variable named sum and use a for loop to intend over the matrix array. Step 4 − ... Read More
275 Views
In this tutorial, we will write a golang program to check whether two matrices are equal or not. A matrix is a collection of numbers arranged in rows and columns, a two-dimensional array. Check Whether Two Matrices are Equal or Not using If Statment In this example we will compare the equality of two matrices using if condition statements. Algorithm Step 1 − Import the fmt package. Step 2 − Start the main() function. Step 3 − Initialize and assign values the two matrices. Step 4 − Print these matrices on the screen. Step 5 − Now use the equality(==) ... Read More
2K+ Views
In this tutorial, we will see to write a go language program to check if two arrays are equal or not. Check If Two Arrays are Equal or Not Using Equality Operator The following code illustrates how we can check if two arrays are equal or not using the equality operator. Algorithm Step 1 − First, we need to import the fmt package that allows us to print anything on the screen. Step 2 − Then we are calling the main() function. Step 3 − Then we are initializing three arrays of integer data type as arr1, arr2, ... Read More
2K+ Views
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 More
647 Views
In this tutorial, we will write a go language program to add two matrices. The difference between a single-dimension array and a multidimensional array is that the former holds an attribute while the latter holds another array on the index. Additionally, every element of a multidimensional array will have the same data type. Adding Two Matrices Using Loops 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 ... Read More
1K+ Views
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 More
1K+ Views
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 More
1K+ Views
Two−dimensional arrays are commonly used in Go. For example, storing data in a table requires a 2D array. In this tutorial, we will be discussing the approach to printing a 2D array in Golang programming. But before writing this code, let’s briefly discuss the two−dimensional array. What is a 2D Array? A 2D array is comprised of rows and columns. Its nature is similar to a normal array with a fixed length. It is homogeneous in nature, i.e., all the elements stored in a 2D array should be of the same data type. If a 2D array has ‘r’ rows ... Read More
4K+ Views
Data plays an essential role when we write programs. It can be stored in multiple ways. For storing a collection of data with the same data type, an array can be used. In this tutorial, we will be discussing the approach to printing an array in Golang programming. But before writing the code for this, let’s briefly discuss the array. What is an Array? An array has a fixed length and its length cannot be altered. It is homogeneous in nature, i.e., all the elements stored in an array should be of the same data type. If an array has ... Read More
992 Views
In this tutorial, we will be discussing the approach to creating a simple class in Golang programming. However, before writing the code for this, let’s briefly discuss the concept of class. What is Class? A class is a template or blueprint for creating objects. A class binds together all the elements of a program and it is an essential part of object−oriented programming. Nevertheless, Go language does not support the ‘class’ keyword unlike other languages like Java, C++, etc. which are object−oriented languages. However, this does not limit Go to using the functionality of a class. Go keeps up with ... Read More