Found 34472 Articles for Programming

Number of jumps required for a thief to cross walls

Riya Kumari
Updated on 12-Jul-2023 12:39:56

173 Views

Imagine a prisoner (or thief) wants to escape from a jail. In order to do so, he needs to cross N number of walls of varying lengths. He can climb X feet for each jump. But, since the walls are slippery, he falls down by Y feet after each jump. So, we need to calculate number of jumps required to cross all the walls. In this article, we will explore different C++ techniques to find the number of jumps required to escape the jail. Input Output Scenarios We have different heights of the N walls in the form of ... Read More

Number of jumps required of given length to reach a point of (d, 0) from origin in 2D plane

Riya Kumari
Updated on 12-Jul-2023 12:35:08

57 Views

In this article, we will discuss the possible solution of an exciting analytical question of how many jumps are required to reach a point (d, 0) from the origin in a 2D plane where you have been specified fixed length of jumps. We will use the fixed length of jumps and the target coordinates to find the minimum number of jumps required. Input Output Scenarios Suppose jump length can be a or b while the target point is (d, 0). Then, the given output is the minimum number of jumps required to reach target. Input: a = 7, b ... Read More

Number of integral solutions for equation x = b*(sumofdigits(x) ^ a)+c

Riya Kumari
Updated on 12-Jul-2023 12:33:41

172 Views

Suppose you are given three integral numbers a, b and c and you have an equation x = b* (sumofdigits(x)^a) +c. Here, sumofdigits(x) is the total sum of all the digits in x. To find all the possible integral solutions which satisfy the equation, we will explore various approaches in C++. Input Output Scenarios Given below are values of a, b and c. Different integral solution which satisfies the equation x = b* (sumofdigits(x)^a) +c is given as output. Input: a = 2, b = 2, c = -3 Output: 125, 447, 575 In the above scenario the ... Read More

Number of horizontal or vertical line segments to connect 3 points

Riya Kumari
Updated on 12-Jul-2023 12:31:43

152 Views

Suppose you are given three different points (or coordinates) and you want to find out number of horizontal or vertical line segments which can be made by connecting those three points. Such line segments together are also known as polyline. You need concepts of computational geometry in order to solve this problem. In this article, we will discuss various approaches in C++ to tackle this problem. Input Output Scenarios Suppose c1, c2 and c3 are coordinates of 3 points in a cartesian plane. The number of horizontal or vertical line segments to connect these 3 points will be given as ... Read More

Number of handshakes such that a person shakes hands only once

Riya Kumari
Updated on 12-Jul-2023 12:29:47

125 Views

Suppose you are in a social gathering. Can you calculate how many handshakes you can do if you were to shakes only once? This question might sound intriguing to you. This can be solved mathematically by using permutations and combinations. However, the mathematical operation might be time-consuming. In this article, we will discuss how to solve such problem using C++. We will explore different approaches which ranges from mathematical formulas, to recursion, and other combinatorial techniques. Input Output Scenarios Suppose you have N number of people in a gathering. You want to calculate the number of handshakes possible ... Read More

Difference between Thread ID and Thread Handle

Pradeep Kumar
Updated on 12-Jul-2023 12:21:03

377 Views

In multi−threaded programming, threads are lightweight units of execution that enable concurrent execution within a single process. Threads share the same memory space and resources of the process, allowing for efficient utilization of system resources. To work with threads, developers often need to distinguish between different threads and manage their execution. This is where the concepts of thread ID and thread handle come into play. In a multi−threaded programming environment, threads are independent units of execution within a process. Each thread has its own unique identifier and a corresponding handle that can be used to manipulate and manage the thread. ... Read More

Number of elements greater than K in the range L to R using Fenwick Tree (offline queries)

Riya Kumari
Updated on 12-Jul-2023 12:28:27

226 Views

In the field of computer science, we have to process large datasets which includes query selection and update operations. It is a challenging task for the developers to execute these operations in real-time with less time complexity. Using Fenwick tree is an efficient way to tackle these range-based query problems. Fenwick Tree is a data structure which updates elements and calculates the prefix sums of the numbers in a table efficiently. It is also known as Binary Indexed Tree. In this article, we will discuss how to use Fenwick Trees for finding the number of elements greater ... Read More

Difference between system() and execl() Call

Pradeep Kumar
Updated on 12-Jul-2023 11:40:28

326 Views

In programming, system−level calls are used to interact with the operating system and perform various tasks. Two commonly used system−level calls are system() and execl(). While both these calls allow executing external programs, they differ in their functionality and usage. What is system() Call? The system() call is a higher−level function that allows the execution of shell commands or scripts. When system() is invoked with a command as its argument, it starts a new shell process, which then interprets and executes the specified command. The system() call provides a simple way to interact with the command line and execute external ... Read More

Number of divisors of product of N numbers

Riya Kumari
Updated on 12-Jul-2023 12:26:49

230 Views

Divisor of a number is which divides it exactly without any remainders. In other words, a divisor of a number n is the one which results in n when multiplied by any other integer. It can also be called as a factor of a number. Dividend ÷ Divisor = Quotient. For example, if we divide 60 with 5 we will get 12 and vice versa therefore, 12 and 60 can be considered as divisors of 60. Number of Divisors of Product of N Numbers Given task is to find the number of divisors of the product of the given ... Read More

Number of divisors of a given number N which are divisible by K

Riya Kumari
Updated on 12-Jul-2023 12:24:02

175 Views

Finding the number of divisors of a given number N which is also divisible by K (any constant number) is a typical mathematical problem which requires lot of calculations. Here, K is usually a number which is less than or equal to square root of N. However, we can construct a C++ program by which counting such numbers will be an easier task. In this article, we will discuss different methods in C++ using which we can find solution to the above given problem. Input Output Scenarios If we consider the below scenario here we have N value as ... Read More

Advertisements