C++ Program to Concatenate Two Strings

In this tutorial you will learn about the C++ Program to Concatenate Two Strings and its application with practical example.

C++ Program to Concatenate Two Strings

In this tutorial, we will learn to create a C++ program that will Concatenate Two Strings in C++ programming.

Prerequisites

Before starting with this tutorial we assume that you are best aware of the following C++ programming topics:

  • Operators in C++ Programming.
  • Basic Input and Output function in C++ Programming.
  • Basic C++ programming.
  • Using Strings in C++ Programming.

Algorithm:-

Program to Concatenate Two Strings

Concatenation means to join two values i.e. Strings. In strings, only one variable is declared which can store a sentence. It’s a collection of characters, digits, and Special characters. First will take the input string one from the user. Then we will take a second-string from the user and now we will concatenate that two stings.

Using the below program example.

Program Code:-

 

Output:-

In the above program, we have first initialized the required variable.

  • str1 = it will hold the string value.
  • str2 = it will hold the string value.
  • result = it will hold the string value.
  • i = it will hold the integer value.

Taking Input string from the user for copying the string.

Concatenating the strings taken from the user with the help of the for loop.

Printing the output Concatenated String.

In this tutorial we have learn about the C++ Program to Concatenate Two Strings and its application with practical example. I hope you will like this tutorial.