Programming Articles

Page 1776 of 2547

What does “!” mean in Java?

Priya Mishra
Priya Mishra
Updated on 23-Aug-2023 2K+ Views

Introduction Java supports eight types of operators; the “!” operator is one of them. In Java, an operator is a symbol used to execute operations. Operators are entities that can modify the values of operands. Java makes authoring, compiling, and debugging code simple. It is helpful in creating code that can be reused and applications that are modular. It was created with the goal of having a few implementation dependencies as feasible. Let’s discuss in detail about the Java operators, “!” operator and where to use it with some working examples. Java operators Operators in Java are symbols that are ...

Read More

What is meant by object in Java?

Priya Mishra
Priya Mishra
Updated on 23-Aug-2023 345 Views

Introduction In real life, we can call tables, chairs, lamps, etc. objects as they have some attributes and functions. We can say that anything that has attributes or properties and some functionality like a lamp has a stand and a bulb and it can light up a room so it is an object. In Java also, we have objects and they have their own properties. Objects are basically the instance of the class and the class provides a blueprint for the creation of an object. Let’s have a brief discussion on objects and how to create an object in Java. ...

Read More

Swapping four Variables without a Temporary Variable

Simran Kumari
Simran Kumari
Updated on 23-Aug-2023 1K+ 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
Simran Kumari
Updated on 23-Aug-2023 298 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
Simran Kumari
Updated on 23-Aug-2023 253 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
Simran Kumari
Updated on 23-Aug-2023 1K+ 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
Simran Kumari
Updated on 23-Aug-2023 411 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

Find the Maximum and Minimum Distance Between Magnets

Simran Kumari
Simran Kumari
Updated on 23-Aug-2023 308 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
Simran Kumari
Updated on 23-Aug-2023 310 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
Simran Kumari
Updated on 23-Aug-2023 746 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
Showing 17751–17760 of 25,466 articles
Advertisements