Articles on Trending Technologies

Technical articles with clear explanations and examples

What is double address operator(&&) in C++?

Akansha Kumari
Akansha Kumari
Updated on 05-May-2025 21K+ Views

&& is a new reference operator defined in the C++11 standard. int&& a means "a" is an r-value reference. && is normally only used to declare a parameter of a function. And it only takes an r-value expression.Simply put, an r-value is a value that doesn't have a memory address. E.g., the number 6 and character 'v' are both r-values. int a, a is an l-value, however, (a+2) is an r-value. Example #include using namespace std; void foo(int&& a) { cout

Read More

What is the difference between cin and cout streams in c++?

Akansha Kumari
Akansha Kumari
Updated on 05-May-2025 17K+ Views

cin is an object of the input stream and is used to take input from input streams like files, console, etc. cout is an object of the output stream that is used to show output. Basically, cin is an input statement while cout is an output statement.They also use different operators. cin uses the insertion operator( >> ) while cout uses the extraction operator( >), which helps to extract the input from the cin and stores it in a variable. It automatically skips the whitespaces (spaces, tabs, newlines) until a special method like getline() is used. Syntax Here is the ...

Read More

Python Program to Print Hollow Rectangle pattern

AYUSH MISHRA
AYUSH MISHRA
Updated on 05-May-2025 2K+ Views

When we start programming then printing different star patterns helps us build our logic and problem-solving skills. One of the easiest and beginner patterns is the hollow rectangle pattern. In this article, we are going to learn how we can print the hollow rectangle pattern using different approaches in Python. Hollow Rectangle Pattern A Hollow rectangle pattern is a rectangle-shaped pattern printing of stars where the stars are present only on the boundaries of the rectangle. The rectangle is hollow, i.e., the stars are printed only on the boundaries of the rectangle, while the inner area remains empty. ***** ...

Read More

How to print the first character of each word in a String in Java?

Vivek Verma
Vivek Verma
Updated on 05-May-2025 8K+ Views

This article will discuss how to print the first character of each word in a given string. For example, if we have the string "Hello John", the output should be H J. In Java, the String class is used to represent character strings. All string literals in a Java program are implemented as instances of the String class. Strings in Java are immutable, which means that once a string is created, its value cannot be changed. To print the first character of each word in a String, we have the following approaches - Using split() ...

Read More

Difference between ArrayList and HashSet in Java

Vivek Verma
Vivek Verma
Updated on 05-May-2025 16K+ Views

In Java, ArrayList and HashSet are the most important classes of the Collection Framework. Both are used to "store collections of elements", but they are used for different purposes and have different characteristics. ArrayList is an "ordered collection" that allows duplicate elements, while HashSet is an "unordered collection" that does not allow duplicates. ArrayList vs HashSet in Java Here are some key differences between ArrayList and HashSet in Java: Key ArrayList HashSet Implementation ArrayList is the implementation of the List interface. HashSet, on the other hand, is the implementation of a set interface. ...

Read More

How can we initialize a boolean array in Java?

Vivek Verma
Vivek Verma
Updated on 05-May-2025 25K+ Views

Initializing a Boolean Array in Java refers to the process of assigning values (allocating memory) to the Boolean array for the first time. We can initialize an array or any variable - Either at the time of creation. Or, later in the program, using the assignment operator when we are just defining it initially. A Boolean array can be used to store only Boolean values (i.e., either true or false), and the "default value" of each element in a Boolean array is false.  In some cases, we may need to initialize all ...

Read More

C++ Program to Generate Random Numbers Using Multiply with Carry Method

Ravi Ranjan
Ravi Ranjan
Updated on 05-May-2025 443 Views

The multiply-with-carry method is a variant of the add-with-carry generator introduced by Marsaglia and Zaman (1991). The main advantages of this method are that it invokes simple computer integer arithmetic and leads to a very fast generation of sequences of random numbers with immense periods, ranging from around 260 to 22000000. In this article, our task is to generate random numbers using the multiply-with-carry method. Here is the formula of multiply-with-carry method: Multiply With Carry (MWC) Formula The multiply-with-carry formula is as follows: Xn = (a * Xn-1 + Cn-1) mod 232 Cn = (a * Xn-1 + Cn-1) ...

Read More

What are the key differences between Python 2.7.x and Python 3.x?

Sumana Challa
Sumana Challa
Updated on 02-May-2025 572 Views

Python 3.0 was released in December 2008. It was designed to rectify certain flaws in earlier versions. Python 3.0 doesn’t provide backward compatibility. That means a Python program written using version 2.x syntax doesn’t execute under the Python 3.x interpreter. Version 2.7 is the final major release in the Python 2.x series. The guiding principle of Python 3 was: "reduce feature duplication by removing old ways of doing things". Although there are quite a few differences in usage of these two versions, the most obvious ones are mentioned below - Print Statement Vs Function print is a keyword in Python ...

Read More

How to remove all special characters, punctuation and spaces from a string in Python?

Yaswanth Varma
Yaswanth Varma
Updated on 02-May-2025 7K+ Views

It is necessary to clean up the strings by removing the unwanted elements such as special characters, punctuation, and spaces. These unwanted characters can be involved in the tasks and cause unexpected results. In this article, we are going to learn more about removing all special characters, punctuation and spaces from a string. Using Python re Module Through the re module, Python provides support for regular expressions. This module contains methods and classes that we can search, match, and modify a string (text content) using regular expressions.ThePython re.sub() method accepts a pattern, a replacement string, and a string as ...

Read More

Python Program to count nodes in a binary tree

AYUSH MISHRA
AYUSH MISHRA
Updated on 02-May-2025 3K+ Views

In this article, we are going to learn how we can count the total number of nodes in a binary tree in Python, using different approaches. A binary tree is a data structure in which each node can have at most two children. The two children node of a binary tree are called the left child and the right child. We have to calculate the total number of nodes present in the binary tree. Scenario 1 Input: Binary Tree = 1 2 3 4 5 Output: Total number of nodes: 5 Above-given binary tree has five nodes: 1, 2, ...

Read More
Showing 1101–1110 of 61,248 articles
« Prev 1 109 110 111 112 113 6125 Next »
Advertisements