Found 7197 Articles for C++

How are Java and C++ related?

Priya Mishra
Updated on 23-Aug-2023 12:54:52

217 Views

Introduction These days, Java and C++ are widely utilized in competitive programming. These two programming languages are utilized generally in industry and competitive programming due to their impressive characteristics. C++ is a commonly used programming language due to its efficiency, fast speed, and dynamic memory use. In terms of software development, Java is incomparable to any other programming language. Java is extensively utilized in the IT sector. Now we will look into how Java and C++ are similar. What is Java? Java is an Object-Oriented programming, general-purpose, and high-level language. It is mainly used for coding web applications. Java ... Read More

Swapping four Variables without a Temporary Variable

Simran Kumari
Updated on 23-Aug-2023 10:43:22

950 Views

By the title "Swapping four variables without a temporary variable, " What do you understand? Let's decode. Here the question is asking us to swap the values of four variables without creating any additional temporary variables. Using a temporary variable to hold one of the values temporarily in various programming languages makes shifting the values of two variables simple. The use of temporary variables, however, becomes ineffective and time−consuming when swapping the values of more than two variables. Explanation Suppose we have four variables a, b, c, and d with the following values: a = 5 (101) b = 9 ... Read More

Sum of Bitwise AND of all Possible Subsets of given Set

Simran Kumari
Updated on 23-Aug-2023 10:41:45

210 Views

What do you understand by the problem `Sum of bitwise AND of all possible subsets of given set`? Let’s decode. The problem is asking to find the sum of the bitwise AND of all possible subsets of a given set. Let’s try to understand the problem with an example. Suppose we have a set {1, 2, 3}. What are the possible subsets for this set? The possible subsets are {1}, {2}, {3}, {1, 2}, {1, 3}, {2, 3}, and {1, 2, 3}. Now lets calculate the bitwise AND for each subset. The bitwise AND of these subsets can be calculated ... Read More

Squares of Numbers with Repeated Single Digits

Simran Kumari
Updated on 23-Aug-2023 10:40:22

168 Views

What is the question `Square of numbers with repeated single digits` asking us to do? Let’s decode! The problem "Squares of numbers with repeated single digits" aims to find the square of numbers like 33, 44, 555, etc which contains repeated single digits. Approach 1: Naive Approach We can use the naive approach to calculate the square of numbers, which includes the following steps: Take the numbers as input Use the multiplication operator to calculate the square i.e square_of_number= number * number then print the result Implementation in C++ Here is the implementation of above approach Example #include ... Read More

Segregate Even and Odd Numbers

Simran Kumari
Updated on 23-Aug-2023 10:39:10

971 Views

What do you understand by the title `Segregate even and odd numbers` ? Let’s decode. The goal of this problem is to separate the even and odd numbers in the input array while preserving the order of the elements, which means that the even numbers should remain in the same relative order as they were in the input, and the odd numbers should remain in the same relative order as they were in the input. Suppose we have [3, 5, 2, 6, 8, 9, 10, 11] as input, then the output will be [2, 6, 8, 10, 3, 5, ... Read More

Reflection of a Point at 180-Degree Rotation of Another Point

Simran Kumari
Updated on 23-Aug-2023 10:37:13

301 Views

What do you understand by the heading `Reflection of a point at 180−degree rotation of another point`? Let’s decode it in this article. Let's assume we have two points (x1, y1) and (x2, y2) in a 2−D plane. Where (x2, y2) is the point of rotation and (x1, y1) is the point to be reflected. Now, suppose x1, y1 is rotated 180 degrees across x2, y2 , and we get x1`, y1`. Now, we can observe that, if we are given 2 points in a 2−d plane with one of the points rotating across the second point it ... Read More

Maximize a Value for a Semicircle of a given Radius

Simran Kumari
Updated on 24-Aug-2023 10:00:49

116 Views

What do understand by the question embedded in the title i.e Maximize a value for a semicircle of a given radius? The title `Maximize a value for a semicircle of a given radius` sounds unclear. Isn’t it? Let’s discuss what it means in the article below: According to the title, If we have a semicircle with radius R, we need to find the maximum value of the expression F = PS^2 + PQ, where P is a point on the circumference of the semicircle, and PQ and PS are the two segments connecting P to the two endpoints of ... Read More

Find the Maximum and Minimum Distance Between Magnets

Simran Kumari
Updated on 23-Aug-2023 10:18:35

212 Views

In this problem, we need to calculate the separation between two magnets that are attached to distinct pivots. We need to calculate the maximum and minimum distance between magnets i.e when the magnets attract and when they repel. The string's length between each magnet and the pivot is specified. Depending on their polarity, the magnets will either repel or attract one another. Calculating the distance between the two magnets when they are attracted and repelling one another is the task. Using the distance formula and taking the polarity of the magnets into account, the issue can be resolved. To calculate ... Read More

Dodecagonal Number

Simran Kumari
Updated on 23-Aug-2023 10:17:01

201 Views

What do you understand by the Dodecagonal number? In order to understand the Dodecagonal number, we first need to understand a dodecagon. What is a Dodecagon? A polygon with twelve sides and twelve angles is called a dodecagon. It is a two−dimensional geometric shape that may be created by joining twelve line segments, each of which forms a closed loop when it connects with two other segments. Every side and angle of a normal dodecagon are equal to one another. A dodecagon's interior angles add up to 180(n−2) degrees, where n is the number of sides. As a result, a ... Read More

Print the Fibonacci Sequence using 2 Variables

Simran Kumari
Updated on 23-Aug-2023 10:15:42

595 Views

What comes to your mind when reading the title? Here we need to calculate the Fibonacci sequence using only 2 variables. First, What is Fibonacci Sequence? The Fibonacci series is a set of numbers where each number is the sum of the two numbers before it. Any number after 0 and 1 is the sum of the two numbers before it. 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946, ... Many fascinating mathematical features and applications of the Fibonacci series may be found in a ... Read More

Advertisements