Python does not have a data type for dates, but we may import the datetime module to work with dates as date objects. Calculating dates that are months apart from a given date is quite challenging due to the varying length of months in our calendar system. This article tells about how to display the current date by importing the datetime module. There are two main methods to calculate a date six months from now in Python, which includes - Using relativedelta() function Using timedelta() function Using relativedelta() Function ... Read More
The cin, cout, cerr, and clog are streams that handle standard input and output stream objects, which are defined in an header file. Standard Output Stream (std::cout) The cout is an object of class ostream that represents the standard output stream oriented to narrow characters (of type char). It corresponds to the C stream stdout. The standard output stream is the default destination of characters determined by the environment. This destination may be shared with more standard objects (such as cerr or clog). Syntax Here is the following syntax for cout in C++: cout
Rabin-Miller algorithm is a probabilistic primality test algorithm that is used to checks if a given number is likely to be a prime number or not. It is similar to the Fermat's primality test and the Solovay-Stressen test. In this article, we have a number 'p'. Our task is to implement the Rabin-Miller algorithm to check if the given number is a prime number or not in C++. Example Here is an example of checking prime numbers using the Rabin-Miller algorithm: Input: p = 41 Output: 41 is a prime nnumber Here is the explanation of the ... Read More
The Sieve of Sundaram method is used to generate the prime number within the given range. In this method, first we mark the indices with prime number using the mathematical formula. Then, we use the unmarked indices to get the prime numbers within the given range. In this article, we have defined a range i.e. 'm = 30'. Our task is to generate prime numbers up to 'm' using the Sieve of Sundaram method in C++. Example Here is an example of generating prime numbers up to 10 using the Sieve of Sundaram method: Input: M = 10 Output: ... Read More
In C, a pointer is a variable whose value is the address of another variable or memory block, i.e direct address of the memory location. Like any variable or constant, you must declare a pointer before using it to store any variable or block address. Basic Pointer to a Function A pointer to a function is simply a variable that stores the address of a function instead of a normal data value. Syntax Following is the syntax of basic pointer to a function: Datatype *variable_name Algorithm Following is the algorithm for the basic pointer to a Function: Begin. ... Read More
Clamping refers to limiting a number to a specific range, i.e., making sure that the number lies between the minimum and maximum value mentioned. This method is used in applications like graphics and statistical computations, as it requires the data to stick to specific limits. Clamping Floating Numbers in Python The following are some of the approaches to clamp floating numbers in Python - Creating a User-Defined Function Since Python has no built-in clamp function, in the following program, we will create our clamp() function, which takes three parameters - n (number to be clamped), min (minimum value), and max (maximum ... Read More
In C++, we can work with files to read, write, or even combine(append) their contents. Here, our task is to append the content of one text file to another. Imagine a scenario where we have two txt files which is named as 'source.txt' and 'destination.txt' files. So, with the help of these files we need to copy everything from the source file and append it at the end of the destination file. ExampleHere, we are giving an input as two text files as source.txt and destination.txt to append content in C++: source.txt file contains "Tutorials" destination.txt file contains "point" ... Read More
Every program runs as a process in Linux operating system. When a process ends or gets disconnected from its parent, special types of processes can be created. These processes are known as zombie and orphan processes. Details about the zombie and orphan processes are given as follows: Zombie Processes A zombie process is a process whose execution is completed but it still has an entry in the process table. Zombie processes usually occur for child processes, as the parent process still needs to read its child's exit status. Once this is done using the wait system call, the zombie process ... Read More
In this article, we will learn how an IllegalStateException (unchecked) is thrown in Java. IllegalStateException is a subclass of RuntimeException. It occurs when a method is used at the wrong time or when an object is not in the right state. What is an IllegalStateException? An IllegalStateException is an unchecked exception in Java. This exception may arise in our Java program mostly if we are dealing with the collection framework of java.util.package. There are many collections, such as List, Queue, Tree, and Map, of which List and Queues (Queue and Deque) throw this IllegalStateException under particular conditions. When will ... Read More
The GUI in Java processes the interactions with users via mouse, keyboard, and various user controls such as buttons, checkboxes, text fields, etc., as events. These events are to be handled properly to implement Java as an Event-Driven Programming. What is Event Handling? Event handling refers to the mechanism that controls events and determines the actions taken when an event occurs. This mechanism includes code known as an event handler, which is executed in response to an event. Components in Event Handling The following are the three main components of event handling in Java: Events ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP