C++ Code to Decrease Even Numbers in an Array

Farhan Muhamed
Updated on 30-Jul-2025 15:33:44

320 Views

An array is a group of similar elements stored together in a single variable which take contiguous memory locations. Arrays help us to store and manage multiple values of the same type, like a list of numbers or names.In this article, we will solve a beginner level problem in C++ that involves decreasing all the even numbers in an array by 1. Program to Decrease Even Numbers in an Array How to Check a if Number is Even in C++? C++ Program to Decrease Even Numbers ... Read More

Path Between Two Vertices in a Directed Graph

Farhan Muhamed
Updated on 30-Jul-2025 15:31:43

1K+ Views

A directed graph is a graph where the edges specify a direction from one vertex to another. In this article, we will learn how to find a path between two vertices in a directed graph and implement C++ code to achieve this. To determine if there is a path between two vertices, there are two common algorithms we can use: BFS Algorithm to Find Path Between Two Vertices DFS Algorithm to Find Path Between Two Vertices First of all, let's understand what does it meant by having a ... Read More

Check If a Large Number Is Divisible by 11 in C++

Akansha Kumari
Updated on 30-Jul-2025 15:19:13

611 Views

In this article, we are given a larger number and we need to check whether it is divisible by 11 or not using the C++ program. To handle large numbers, we treat the number as a string and apply a divisibility rule to check if it's divisible by 11. Rule of Divisibility by 11 A number is divisible by 11 if the difference between the sum of its digits at odd positions and the sum of its digits at even positions is divisible by 11. Consider the following example scenarios to understand the divisibility of a large number ... Read More

Check If All Bits of a Number Are Set in Python

Yaswanth Varma
Updated on 30-Jul-2025 15:14:27

435 Views

In computers, data is stored in the binary form, which uses the two digits 0 and 1. Each digit in this format is known as a bit. In this article, we are going to check if all bits of a number are set in Python. A bit is said to be set if the binary representation of every bit is 1. Let's look at some scenarios to understand this better: Scenario 1 Input: 3 Binary: 111 Output: True Explanation: All bits are 1. Scenario 2 Input: 6 Binary: 110 Output: False Explanation: Not all bits are 1. ... Read More

What Does the Operation C + A++ + B Mean in C/C++?

Aman Kumar
Updated on 30-Jul-2025 15:03:20

2K+ Views

In C/C++, the expression c = a++ + b indicates that the current value of a is added to b, and the result is assigned to c. After this assignment, a is incremented by 1 (post-increment), which means the increment of a happens after its value is used in the expression. Well, let a and b initialize with 2 and 5, respectively. This expression can be taken as two different types. c = (a++) + b c = a + (++b) The above two expressions contain both post and pre-increment ... Read More

Angle Between Two Planes in 3D Using C Program

Aman Kumar
Updated on 30-Jul-2025 14:13:45

167 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. In this article, we will learn how to calculate the angle between two planes in 3D space using a C program. The diagram below illustrates two planes intersecting in 3D space. These planes can be represented by the following equations: Equation P1: a1 * x + b1 * y + c1 * z + d1 = 0 P2: a2 * x + b2 * y + c2 * ... Read More

Print Level Order Traversal Line by Line in C++ Programming

Aman Kumar
Updated on 30-Jul-2025 13:09:16

393 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

Add Two Binary Strings in C++

Nishu Kumari
Updated on 29-Jul-2025 18:52:05

276 Views

We are given n binary strings, and we need to add them together and return the result (as a binary string). A binary string is a string that consists only of the characters '0' and '1', which represent binary digits. We will add them bit by bit using binary addition rules. Addition of Binary Numbers Here's how binary addition with binary numbers works: 1 + 0 = 1 0 + 1 = 1 0 + 0 = 0 1 + 1 ... Read More

Get Size of Java LinkedHashSet

Aishwarya Naglot
Updated on 29-Jul-2025 18:49:52

385 Views

LinkedHashSet is a collection in Java that maintains the insertion order of elements. It is part of the Java Collections Framework and extends the HashSet class. It stores unique elements and allows null values, but only one null element. It is similar to HashSet; the main difference is that a LinkedHashSet maintains a linked list holding of the entries of the current object, allowing it to maintain the order of elements. Let's learn how to get the size of a LinkedHashSet in Java. The following are some example scenarios: Scenario 1 Input : set = {1, 2, 3, 4, ... Read More

Get Element from a Stack in Java Without Removing It

Aishwarya Naglot
Updated on 29-Jul-2025 18:46:42

3K+ Views

The Stack is a data structure that is used to store elements in a Last In First Out (LIFO) manner. In Java, a stack is represented by the java.util.Stack class. It provides methods to create and manipulate a stack. Get an Element of a Stack without Removing it The pop() method of the Stack class removes the element at the top of the stack and returns it. But there is no direct way to access an element without removing it. However, we can see/view the top element of a Stack in Java using the peek() method. This method returns the ... Read More

Advertisements