Programming Articles - Page 578 of 3363

C++ Program to calculate the Highest Common Factor

Arnab Chakraborty
Updated on 04-Apr-2023 14:13:10

2K+ Views

The highest Common Factor or Greatest Common Divisor are factors that are maximum and that can divide two or more values without generating any remainder. In this article, we shall discuss a few methods to perform HCF / GCD between two numbers in C++. This is simply a mathematical solution and there are several algorithms present to find GCD. The Euclidean method to find GCD is common. The same algorithm we will use in iterative mode, and recursive mode. Using Iterative method The iterative solution for the Euclidean gcd finding algorithm is shown in the algorithm section. Algorithm ... Read More

C++ Program to read the height of a person and the print person is taller, dwarf, or average height person

Arnab Chakraborty
Updated on 17-Oct-2022 12:49:05

1K+ Views

A person’s height determines whether he/ she is tall, dwarf, or average height person. In different regions of the world, the height ranges are different. We are considering Indian standards. In this article, we shall cover how to write a simple program to determine whether a person is taller, dwarf, or of average height person in C++. Let us define the height range and corresponding classification first, then we can use them in the algorithm as well as in our implementation. Height (cm) Type 150 – 170 Average 170 – 195 Tall Below ... Read More

C++ Program to calculate the volume and area of Sphere

Arnab Chakraborty
Updated on 17-Oct-2022 12:46:21

9K+ Views

The Sphere is a ball-like 3D object whose all sides are curved surfaces. On a sphere, no plane surface is there. The volume of a sphere is actually how much space it is taking in the space. In this article, we shall cover the techniques to calculate the volume and the surface area of a sphere in C++. A sphere has one basic parameter. The radius π‘Ÿ. We will see the techniques to calculate the volume and area one by one. The volume of a Sphere To calculate the volume of a sphere, we need one input, the radius π‘Ÿ. ... Read More

C++ Program to calculate the volume and area of the Cylinder

Arnab Chakraborty
Updated on 17-Oct-2022 12:39:52

9K+ Views

The cylinder is a tube-like 3D object whose base is a circle and has a certain height. The volume of a cylinder is actually how much space it is taking in the space. In this article, we shall cover a few techniques to calculate the volume and the surface area of a cylinder in C++. A cylinder has two basic parameters. The height β„Ž and the radius of its bases π‘Ÿ. The surface area of a cylinder can have two variations. Only the outer curved surface (for hollow and both side open cylinder) and area with the curved surface with ... Read More

C++ Program to calculate the volume of Cube

Arnab Chakraborty
Updated on 17-Oct-2022 12:34:48

5K+ Views

Cubes are the basic 3D objects which have 8 vertices, 12-edges, and 6-faces. The volume of a 3D object is how much space it is occupying in the world. In this article, we will see how we can calculate the volume of a cube by writing a C++ program. A cube has all edges of equal length. The area for each face is π‘˜2 where π‘˜ is the length of each side. As 3D objects have length, breadth, and width, so the volume of it will be π‘˜3. Let us see the algorithm and corresponding C++ implementation to find the ... Read More

C++ Program to calculate the sum of all odd numbers up to N

Arnab Chakraborty
Updated on 17-Oct-2022 12:27:52

14K+ Views

Getting series sum is one of the simplest practicing tasks while we are learning programming and logic build up. In mathematics, there are certain ways to find sum of series present in different progressions. In programming, we generate them one by one by implementing the logics, and repeatedly add them to get the sum otherwise perform any other operation if needed. In this article we shall cover techniques to get sum of all odd numbers up to N using C++. There are two possible ways to get this sum with a little variation. Let us see these approaches one by ... Read More

C++ Program to Print the Multiplication Table in Triangular Form

Arnab Chakraborty
Updated on 17-Oct-2022 12:24:43

771 Views

To memorise the few fundamental multiplication results in tabular or graphic form, use multiplication tables. This article will cover how to produce a multiplication table in C++ that looks like a right-angled triangle. In a select few situations where a larger number of results may be easily memorised, triangular representation is effective. In this format, a table is shown row by row and column by column, with each row containing only the entries that fill that column. To solve this problem, we need basic looping statements in C++. For displaying the numbers in triangular fashion, we need nested looping to ... Read More

C++ Program to Get Input from the User

Arnab Chakraborty
Updated on 04-Apr-2023 14:14:55

2K+ Views

While writing a program in any language, taking input is a fundamental job that we do in almost all programs. Sometimes we take input directly from the console or take the inputs from the files. Taking inputs from the files is somewhat beneficial because it does not require us to type inputs again and again, or sometimes we can save some good input test cases into a file. However, in this article, we are going to focus on console-based inputs. We will learn different techniques to get inputs from the user in C++. There are a few different approaches to ... Read More

C++ Program to Round a Number to n Decimal Places

Arnab Chakraborty
Updated on 17-Oct-2022 12:11:09

25K+ Views

Representing numbers in outputs is an interesting and also important task while we are writing programs in any language. For integer type (short, long, or medium) type data, it is easy to express the numbers as output. For floating point numbers (float or double type), sometimes we need to round them off to certain decimal places. For example, if we want to represent 52.24568 up to three decimal places, some pre-processing needs to be done. In this article, we shall cover a few techniques to represent a floating-point number up to a certain decimal placed by rounding it off. Among ... Read More

C++ Program to Calculate simple interest and compound interest

Arnab Chakraborty
Updated on 17-Oct-2022 09:22:53

27K+ Views

After calculating interest on the principal amount, simple interest is calculated by taking the principal amount, the rate of interest, and the number of years it will take to calculate interest. The formula is quite easy to understand. The power law is used to calculate compound interest by taking into account the principal amount, the rate of interest, and the period. Here, the formula is likewise not difficult. In this article, we'll talk about how to calculate simple and compound interest values and then use the C++ programming language to put this logic into practice. Simple Interest Simple interest is ... Read More

Advertisements