Aman Kumar

Aman Kumar

62 Articles Published

Articles by Aman Kumar

62 articles

Angle between two Planes in 3D in C Program?

Aman Kumar
Aman Kumar
Updated on 15-Mar-2026 264 Views

In 3D geometry, planes are flat surfaces extending infinitely in space. When two planes intersect, they form a line, and the angle between them becomes an important geometric measure. The angle between two planes is calculated using their normal vectors and the dot product formula. Syntax angle = acos(dot_product / (magnitude1 * magnitude2)) * (180 / PI) Plane Equations Two planes in 3D space can be represented by the following general equations − P1: a1 * x + b1 * y + c1 * z + d1 = 0 P2: ...

Read More

What does the operation c=a+++b mean in C/C++?

Aman Kumar
Aman Kumar
Updated on 15-Mar-2026 2K+ Views

In C, the expression c = a+++b is parsed by the compiler using the "maximal munch" rule, which means it reads the longest possible token sequence. This expression is interpreted as c = (a++) + b, where a++ is the post-increment operator applied to variable a. Syntax c = a++ + b; // Post-increment a, then add b c = a + ++b; // Pre-increment b, then add to a The key difference lies in operator precedence and associativity. The post-increment operator (++) has higher precedence than the addition ...

Read More

Find total number of distinct years from a string in C++ Program

Aman Kumar
Aman Kumar
Updated on 07-Aug-2025 791 Views

In this article, we will write a C++ program to find the total number of distinct years from a string. Here, we have a string that contains the words and the dates. Our task is to find the number of distinct years mentioned. Let's see the following example scenario to understand the problem better: Scenario 1 Input: str = "The Berlin Wall fell on 09/11/1989. The first website was launched on 06/08/1991." Output: Total number of distinct years: 2 Explanation: Two distinct years are referenced: 1989, and 1991 Scenario 2 Input: str = "TutorialsPoint India was founded on ...

Read More

Find the first, second and third minimum elements in an array in C++ program

Aman Kumar
Aman Kumar
Updated on 06-Aug-2025 702 Views

In this article, we need to identify the three minimum elements in an array: minimum, second minimum, and third minimum. We will look at two different approaches to solve this problem and compare their time complexity. Problem Statement Given an array of n elements, we need to find the first, second, and third minimum elements in the array. The first minimum is the minimum of the array's elements, the second is a minimum but larger than the first, and the third is a minimum but larger than the second. Let us see the following example scenario to understand the problem ...

Read More

Order of evaluation in C++ function parameters

Aman Kumar
Aman Kumar
Updated on 04-Aug-2025 360 Views

In C++, when we pass multiple arguments to a function, a common question arises, in what order are these arguments evaluated? Is it from left to right, right to left, or does it depend on the compiler? In this article, we will learn how function parameter evaluation works in C++, why the order of evaluation is important, and how it can vary across different compilers. Is the Order of Evaluation Defined in C++? The C++ standard does not guarantee a fixed order of evaluation for function arguments. This means compilers are free to evaluate arguments from left to ...

Read More

Print level order traversal line by line in C++ Programming.

Aman Kumar
Aman Kumar
Updated on 30-Jul-2025 524 Views

Level Order Traversal, also known as Breadth-First Search (BFS), is a method of traversing a tree where nodes are visited level by level, starting from the root node and moving left to right within each level. In this article, our task is to print the nodes of a binary tree in level order, with each level displayed on a separate line. For example, if the binary tree (consider the below image) is traversed in level order. The output will look like this: 1 2 3 4 5 Printing Level Order Traversal Line by Line The following are the ...

Read More

3-way Merge Sort in C++

Aman Kumar
Aman Kumar
Updated on 29-Jul-2025 2K+ Views

Merge sort is a popular sorting algorithm that follows the divide-and-conquer strategy. It works by recursively dividing the input array into two halves, sorting each half, and then merging them. With a time complexity of O(n log n). 3-Way Merge Sort An optimized variation of merge sort is the 3-way merge sort, where the array is divided into three equal parts instead of two. This reduces the number of recursive calls and improves performance in certain scenarios. 3-Way Merge Sort algorithm Following are the steps (algorithm) to implement the 3-way merge sort: Divide the array ...

Read More

3Sum Closest in C++

Aman Kumar
Aman Kumar
Updated on 29-Jul-2025 2K+ Views

The 3 Sum Closest problem involves finding the sum of three numbers in an array that is closest to a given target value. We are given an integer array nums of length n and an integer target. Our goal is to find three integers in the array such that their sum is as close as possible to the target using C++ program. In this task, we assume that each input has exactly one solution. If there are multiple sums equally close to the target, we return the maximum one. Let's consider the following example scenario to understand the problem more ...

Read More

Area of a polygon with given n ordered vertices in C++

Aman Kumar
Aman Kumar
Updated on 29-Jul-2025 1K+ Views

A polygon is a closed two-dimensional shape formed by connecting three or more straight lines end-to-end. These lines form sides, and their connection points are called vertices. When the vertices of the polygon are given in a specific order either clockwise or counter-clockwise, we can calculate the area of the polygon using a mathematical formula known as the Shoelace Formula or Surveyor’s Formula. You are given the coordinates of a polygon with n vertices. The vertices are provided in an ordered manner, meaning they are listed either in clockwise or anticlockwise order starting from the first vertex to the last. ...

Read More

Are array members deeply copied in C++?

Aman Kumar
Aman Kumar
Updated on 24-Jul-2025 1K+ Views

In C++, an array member is simply the individual elements stored within an array. What is Deep Copy? A deep copy creates a new object and allocates separate memory for the dynamically allocated resources; it copies all the data members of the original object into the new object. So that the new object is completely independent of the original. When a class has a pointer to dynamic memory, the default copy constructor and assignment operator will perform a shallow copy, which is a copy of the pointer rather than the data. So, must define our own ...

Read More
Showing 1–10 of 62 articles
« Prev 1 2 3 4 5 7 Next »
Advertisements