Saumya Srivastava

Saumya Srivastava

10 Articles Published

Articles by Saumya Srivastava

10 articles

Golang program to print a 2D array?

Saumya Srivastava
Saumya Srivastava
Updated on 28-Dec-2022 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

Golang Program to Create a Simple Class?

Saumya Srivastava
Saumya Srivastava
Updated on 28-Dec-2022 1K+ 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

Golang program to find the area of a rectangle

Saumya Srivastava
Saumya Srivastava
Updated on 21-Nov-2022 961 Views

This tutorial will discuss how to find the area of a rectangle in Golang programming using two methods − Area of the rectangle using length and breadth Area of the rectangle using diagonal and breadth Rectangle A rectangle is a two-dimensional shape that has four sides. The opposite sides of a rectangle are equal and all the angles of a rectangle are at 90°. Another property of a rectangle is that its opposite sides are parallel to each other. Area of a rectangle The total space enclosed within the boundary of the rectangle is known as the area ...

Read More

Golang program to calculate the volume of a cube

Saumya Srivastava
Saumya Srivastava
Updated on 21-Nov-2022 424 Views

In this tutorial, we will be discussing the approach to finding the volume 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 volume. 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. Volume of a cube The total three-dimensional space occupied by the cube is known as the volume of ...

Read More

Golang program to calculate the volume and area of the Cylinder

Saumya Srivastava
Saumya Srivastava
Updated on 21-Nov-2022 314 Views

In this tutorial, we will be discussing the approach to calculate the volume and area of a cylinder in Golang programming using its height and radius. But before writing the code for this, let’s briefly discuss the cylinder and its volume and area. Cylinder A cylinder is a three-dimensional figure whose base has a circular shape. The distance between the two bases is known as the cylinder’s height ‘h’ and the radius of the base is denoted by ‘r’. A cold drink can is a good example of a cylinder. Volume of a cylinder The capacity ...

Read More

Golang program to calculate the volume and area of a Sphere

Saumya Srivastava
Saumya Srivastava
Updated on 21-Nov-2022 371 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
Saumya Srivastava
Updated on 21-Nov-2022 388 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
Saumya Srivastava
Updated on 21-Nov-2022 661 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
Saumya Srivastava
Updated on 21-Nov-2022 592 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
Saumya Srivastava
Updated on 21-Nov-2022 381 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
Showing 1–10 of 10 articles
« Prev 1 Next »
Advertisements