Check If a Number is an Empire Number in Java

Vivek Verma
Updated on 13-Jun-2025 12:08:36

437 Views

What is Empire Number? A number is said to be an Empire number if it is a prime number, and when we reverse that number, we should get another prime number. For example, let's consider the number 17. We know that 17 is a prime number, and if we reverse this number, we get 71, which is also a prime number. Therefore, 17 is known as an empire number. Here are some other examples of prime numbers such as 11, 13, 17, etc. Input & Output Scenarios Below are a few input and output scenarios that help to understand the ... Read More

Check If Point Lies Inside a Rectangle in Java

Vivek Verma
Updated on 13-Jun-2025 12:08:27

3K+ Views

A Rectangle is a closed two-dimensional shape that has 4 sides and 4 corners. The opposite sides are of the same length and parallel to each other. All 4 interior angles are equal, angles measure 90 degrees. It is a four-sided polygon. Following is the diagram of the Rectangle: Checking Points Inside Rectangle A point is said to lie inside a rectangle if its x and y coordinates are between the x and y coordinates of the opposite corners of the rectangle. To determine whether the point lies within the rectangle, we will use the following approaches: ... Read More

Returning Multiple Values from a C++ Function

Aman Kumar
Updated on 12-Jun-2025 17:51:03

9K+ Views

In C++, we cannot return multiple values from a function directly. But, by using some methods (i.e., techniques), we can return multiple values from a function. How to Return Multiple Values from a Function? A function can return only one value using the return statement. We can return multiple values (more than one value) from a function by using the "call by address" and "call by reference" approach in the invoker function. Return Multiple Values from a Function Using Call by Address In C++, the call is an address, also known as a call by pointer. It passes ... Read More

Print Leading Zeros with C++ Output Operator

Aman Kumar
Updated on 12-Jun-2025 17:44:24

7K+ Views

Here we will see how to print leading zeros as output in C++. We know that if we directly put some zeros before some numeric values, then all zeros are discarded, and only exact numbers are printed.Printing Leading Zeros with C++ Output Operator We can manipulate the output sequence in C++ by utilizing the iomanip header. In this header, we have two manipulators, setw() and setfill(). The setw() function is used to create space between the previous text and the current text, and then we use setfill(char) to add characters to that field. Example of Printing Leading Zeros In this ... Read More

When to Use the readNBytes Method of InputStream in Java 9

Alshifa Hasnain
Updated on 12-Jun-2025 17:36:13

2K+ Views

In this article, we will learn to use the readNBytes() method of InputStream in Java 9. We will get to know the InputStream Class with its methods as readNBytes() is a method of this class. After that, we will learn about the readNBytes() method with its syntax and when to use this method, along with an example. InputStream Class The Java InputStream class is the superclass of all classes representing an input stream of bytes. Every subclass of InputStream always needs to introduce a method to return the next byte on request. The following are some of the common methods of ... Read More

Get Parent Process of the Process API in Java 9

Alshifa Hasnain
Updated on 12-Jun-2025 17:32:47

852 Views

In this article, we will learn to get the parent process of the Process API in Java 9. First, we will know about Process API and its methods, after that we will learn about the ProcessHandle interface. Process API In Java, the Process API, we can perform any operation regarding a process. The Process class provides methods for performing input on the processes, performing output to the processes, finding child and parent processes of the currently running process, and destroying the process. The following are some of the common methods of the Process API: destroy(): ... Read More

Explain Quantifiers in Java Regular Expressions

Alshifa Hasnain
Updated on 12-Jun-2025 17:31:35

648 Views

Quantifiers in Java are special characters that allow you to specify the number of times a character or group of characters can occur in a regular expression. The most common quantifiers are: *: One or more instances of the character or set of characters that came before it. ?: The character or set of characters before it, either zero or one instance. ... Read More

C++ Program to Print the Diamond Shape

Farhan Muhamed
Updated on 12-Jun-2025 17:26:36

580 Views

In this article, we will learn how to print a diamond shape with 2n rows and n columns for a given size n using C++. For example, if n = 4, the diamond shape will look like this: Algorithm to Print Diamond Shape To print the diamond shape, we can follow these steps: Take an integer input n from the user. To print upper half of the diamond, use a loop that runs from i = 1 to i

Check If a Graph Can Be Constructed for a Given Degree Sequence in C++

Farhan Muhamed
Updated on 12-Jun-2025 17:23:27

176 Views

We are given an array of integers containing the degree of each vertex in a graph. Our task is to check if it is possible to construct a graph with the given degree sequence. Example: int degrees[] = {3, 2, 2, 0} Output: Not Possible Explanation: The first vertex has degree 3, which means it must be connected to three other vertices. But the last vertex has degree 0, meaning it cannot be connected to any other vertex. Hence, it is impossible to construct a graph with this degree sequence. To implement this in C++, we can ... Read More

Minimum Removals to Make Array Sum Even in C++

Ravi Ranjan
Updated on 12-Jun-2025 17:20:06

258 Views

In this article, we have an array arr[] of N integers. Our task is to write a program to find the minimum number of elements needed to be removed from the given array so that the sum of the remaining elements is even. Example The following example demonstrates the minimum number of elements we need to remove from the array for the sum to be even: Input: arr = {12, 23, 40, 53, 17} Output: 1 Input: arr = {20, 11, 13, 40, 24} Output: 0 The explanation of ... Read More

Advertisements