This article will discuss the difference between dot '.', question mark '?', and asterisk'*' in Python regular expressions. In regular expressions, '.' means any one character except the newline, '*' means zero or more times of the character or group before it. and '?' means zero or one time of the character or group before it. In some types of regex, ? Also makes things non-greedy. As we have seen in Python regular expressions, these symbols have different meanings, so let us understand these symbols using the examples - Usage of Dot (.) The following example will use ... Read More
In this article, we will learn to create pyramid patterns using Java. It will help us to understand how loops work. for loop while loop Java program to create pyramid patterns We are going to print the following pyramid patterns: Half Star Pyramid Inverted Half Star Pyramid Star Pyramid Inverted Star Pyramid Numeric Pyramid Pattern 1: Half Star Pyramid We will initialize the row to 5 and a loop runs from i-1 to i
In this article we will see what are the Stringize operator and Token Pasting operator in C. The stringize operator (#) and the token pasting operator (##) are preprocessor operators used within macros for text manipulation. It sends commands to compiler to convert a token into string. Stringize Operator (#) The stringize operator (#) is a preprocessor operator that converts the micros parameter into a string literal. The preprocessor encloses the actual argument passed to the macro in double quotes, effectively convert it into a string. Syntax Following is the syntax of Stringize Operator: #define MACRO_NAME(arg) #arg ExampleIn ... Read More
In this article, we will see how to convert a Decimal to a Hexadecimal string and versa in C++. For this conversion, we are using the string stream feature of C++. You can use StringStreams for formatting, parsing, converting a string into numeric values, and more. The Hex is an I/O manipulator. It takes a reference to an I/O stream as a parameter and returns a reference to the string after manipulating it. Implementation of converting Decimal to Hexadecimal In the following example, we will see how to convert decimal numbers or hexadecimal numbers in C++. #include #include ... Read More
When we call some functions, the call stack stores the address, and after returning, it pops the address to resume work. What is Stack Unwinding Stack unwinding refers to the process of removing function call frames from the function call stack during runtime, wherein local objects are destroyed in the reverse order of their construction. Why Stack Unwinding Occurs? Stack unwinding occurs when an exception occurs in a function and is not handled immediately in that function. The program control goes back through each function step by step, cleaning up any temporary resources used by each function. How Unwinding Works? ... Read More
In this article, we will explore what happens when we concatenate two string literals in C++. There are two important points to remember when concatenating strings in C++. Concatenation is another property of the string and string literals: let's see the following two properties below: If x + y is the expression of string concatenation, where x and y are both strings. Then the result of this expression will be a copy of the characters of string x followed by the characters of string y. Either x or y can be ... Read More
Inheritance is a concept that allows us to access the properties and behaviors of one class in another class. The class whose methods and member variables are inherited is known as the super class or parent class, and the class that inherits these methods and member variables is known as the child class or subclass. In Java, we use the extends keyword to inherit a class. Problem Statement Write Java programs that calculate interest for Fixed Deposits (FDs) and Recurring Deposits (RDs) using inheritance. The program should prompt the user to choose between FD and RD, enter the amount and duration, ... Read More
To count number of vowels and consonants in a given String, we can use the switch statement and if-else condition in Java. Alphabets that include 'a' 'e' 'i' 'o' 'u' are called Vowels and all other alphabets are called Consonants. Let's understand the problem statement with an example scenario. Example Scenario Suppose our input string is: Input: Hello, my name is Charlie Output: Vowels = 8, Consonants = 12 In the given string, the collective count of vowels is 8 and consonants is 12. Using switch Statement Run a for-loop, check each letter whether it is a consonant or ... Read More
No, we can't create an object of an abstract class. But, we can create a reference variable of an abstract class. The reference variable is used to refer to the objects of derived classes (subclasses of abstract class). An abstract class hides the implementation and shows the function definition to the user. A Java abstract class can have instance methods that implement a default behavior and 0 or more abstract methods. A method which does not have body is known as abstract method. It contains only the method signature and an abstract keyword before it as shown below: public abstract ... Read More
Checking Eligibility of TPP Students in Java Consider the following table for eligibility criteria of different companies for appearing in interviews: CGPA ... Read More