C++ Program to Concatenate Two Strings

Nishu Kumari
Updated on 22-May-2025 19:14:17

1K+ Views

In this article, we'll show how to write a C++ program to concatenate two strings. A string in C++ is a sequence of characters like letters, numbers, symbols, or anything enclosed in double quotes (e.g., "Hello"). Concatenating two strings means joining them together to form one combined string. For example, if we have two strings: str1 = "Welcome to" and str2 = "tutorialspoint!", after concatenation, the result will be: result = "Welcome to tutorialspoint!". Approaches to Concatenate Strings in C++ We can concatenate strings in C++ using different methods. Below are the approaches we will cover: ... Read More

Solve Any Linear Equation in One Variable Using C++

Nishu Kumari
Updated on 22-May-2025 19:13:53

6K+ Views

Any linear equation in one variable has the form aX + b = cX + d. Here the value of X is to be found, when the values of a, b, c, d are given. Let's understand this with an example: //Example 1 If the input equation is 2X + 4 = -9X + 14, the solution is: => 2X + 9x = 14 - 4 => 11X = 10 => X = 10 / 11 = 1.1 //Example 2 If the input equation is -3X + 5 = 4X - 9 the solution is: => -3X + ... Read More

Set Find Function in C++ Programming STL

Revathi Satya Kondra
Updated on 22-May-2025 19:11:59

2K+ Views

In this article we are going to discuss the set::find() function in C++ STL, their syntax, working and their return values. What is Set in C++ STL? Sets in C++ STL are the containers which must have unique elements in a general order. Sets must have unique elements because the value of the element identifies the element. Once added a value in a set container later can't be modified, although we can still remove or add the values to the set. Sets are used as binary search trees. What is set::find() The std::find() function is an inbuilt function in C++ ... Read More

Default Arguments and Virtual Function in C++

Aman Kumar
Updated on 22-May-2025 18:28:36

329 Views

Default Argument A default argument is a value provided during the function declaration that can be automatically assigned if no argument is provided when the function is called. If a value is passed at the time of the function call, this default value is overridden, and the argument becomes a parametrized Argument. Syntax The syntax below shows how we can define a default argument function: int fun(int x = 0){ // function body } Example of Default Argument The following C++ example shows the working of the default argument: #include using namespace std; //function defined with ... Read More

C++ Program to Implement Dequeue

Aman Kumar
Updated on 22-May-2025 18:14:56

12K+ Views

A deque is a double-ended queue linear data structure where elements can be added or removed from both the front and rear ends. Unlike a standard queue which is FIFO. A dequeue can function in both FIFO and LIFO modes. Application of Dequeue Deques are useful in a situation where you need to add or remove an element from both ends, such as in buffer implementation managing undo/redo functions or implementing certain algorithms. Deque Operations Deque supports the following operations: insert_at_beg(): inserts an item at the front of Dequeue. insert_at_end(): inserts ... Read More

Implement Sorted Doubly Linked List in C++

Aman Kumar
Updated on 22-May-2025 18:12:31

2K+ Views

Sorted Doubly Linked List A sorted doubly linked list is a type of doubly linked list in which elements are arranged in a specific order, typically ascending or descending based on the data values. Where, insertion operation makes sure that the new node is placed in its correct sorted position. A doubly linked list is a two-way linked list in which a node is connected with two pointers, i.e., next and previous pointers, which are references to the next node and previous node, respectively. Characteristics of Sorted Doubly Linked List The following are the characteristics of the doubly linked ... Read More

Virtual Functions and Runtime Polymorphism in C++

Aman Kumar
Updated on 22-May-2025 18:11:33

6K+ Views

In C++, both virtual functions and runtime polymorphism are key features that enable dynamic behavior and code flexibility. Virtual Functions A virtual function is the member function that is declared in the base class using the keyword virtual and is overridden in the derived class. The virtual function enables runtime polymorphism means the function that will be executed is determined at runtime rather than at compile time. Characteristics of Virtual Function Following are the characteristics of the virtual function: Virtual function make sure the correct function is called for an object, regardless of the type ... Read More

Implement Sorted Singly Linked List in C++

Aman Kumar
Updated on 22-May-2025 18:10:45

3K+ Views

A singly linked list is a type of linear data structure where each node contains two items: The data and a link to the next node in the list. Where, first node is called as head node and the last node is called the tail. So, you can traverse the linked list from the head node and continue until the link becomes null. Sorted Singly Linked List A singly linked list is supposed to be sorted when its elements are arranged in specific order (i.e., ascending or descending order), and each node contains data and a pointer (or reference) to ... Read More

Implement Wagner and Fisher Algorithm for Online String Matching in C++

Farhan Muhamed
Updated on 22-May-2025 18:06:15

480 Views

Here, we will see how to use Wagner and Fisher algorithm for string matching in C++. Using this algorithm, we can find how many minimum changes are required to match those strings. Wagner Fisher Algorithm Wagner Fisher is a dynamic programming algorithm that is used to find the minimum edit distance or levenshtein distance between two input strings. Levenshtein distance between two strings means the number of changes (ie, insertion, deletion or updation) required to convert one string into another. In simpler words, this algorithm will calculate a minimum number of changes required to convert ... Read More

Left Rotation on a Binary Search Tree in C++

Farhan Muhamed
Updated on 22-May-2025 18:04:56

2K+ Views

A Binary Search Tree (BST) is a sorted binary tree in which each node follows two key properties: The right subtree of a node contains only keys greater than the node's key. The left subtree of a node contains only keys less than the node's key. Additionally, each node has at most two children. Tree Rotation Tree rotation is an operation that changes the structure without interfering with the order of the elements on a binary tree. It moves one node up in the tree and one node down. ... Read More

Advertisements