write a c++ program to input two strings and print their lengths, concatenate them and print the result and also print both the strings by swapping their first element

write a c++ program to input two strings and print their lengths, concatenate them and print the result and also print both the strings by swapping their first element

#include <iostream>
#include <string>
using namespace std;

int main() 
{
    int l,m;
    string a,b,c,d;
    cin>>a>>b;
    l=a.size();
    m=b.size();
    cout<<l<<" "<<m<<endl;
    c=a+b;
    cout<<c<<endl;
    d[0]=a[0];
    a[0]=b[0];
    b[0]=d[0];
    cout<<a<<" "<<b;
    return 0;
} 

Comments

Popular posts from this blog

NITs Gate Vlsi cutoff

Swap Nodes in Pairs using recursion in cpp