#include<iostream>
#include<cstring>usingnamespacestd;intmain(){strings1,s2,s3;cout<<"———————————————————————————————————————————";cout<<"\nProgram to swap the given strings";cout<<"\n———————————————————————————————————————————";cout<<"\ns1=";getline(cin,s1);cout<<"s2=";getline(cin,s2);s3=s1;s1=s2;s2=s3;cout<<"———————————————————————————————————————————";cout<<"\nAfter swapping...";cout<<"\n———————————————————————————————————————————";cout<<"\ns1="<<s1;cout<<"\ns2="<<s2;cout<<"\n———————————————————————————————————————————\n";return0;}
Output
codeaft@codeaft:~$ g++ codeaft.cpp codeaft@codeaft:~$ ./a.out
———————————————————————————————————————————
Program to swap the given strings
———————————————————————————————————————————
s1=Hi There!
s2=How are you today?
———————————————————————————————————————————
After swapping...
———————————————————————————————————————————
s1=How are you today?
s2=Hi There!
———————————————————————————————————————————
codeaft@codeaft:~$
Dear User, Thank you for visitng Codeaft. If you are interested in technical articles, latest technologies, and our journey further, please follow us on LinkedIn.