How we can add two string objects in c++ code


It is very easy. First, we make three objects and input two objects and add two objects and give value of third object. You can see the code of how we can add string objects in c++ to understand deeply.

Code:

#include <iostream>
#include <string>
using namespace std;
int main() {
 string s1,s2,s3;
 cout<<"Enter first name : ";
 cin>>s1;
 cout<<"Enter last name : ";
 cin>>s2;
 s3=s1+s2;
 cout<<"Full Name : "<<s3;
}

Input:

Enter first name : muhammad
Enter last name : abbas
Full Name : muhammadabbas

So, you can see how we can add two names first and last.

Click here and watch the video of that code


avatar
AUTHOR: Muhammad Abbas
I am Software Engineer.

0 Comments