Tuesday, 13 September 2016

Hacker Rank Solution Program In C++ For " Strings "

Problem :- Hacker Rank Solution Program In C++ For " Strings "

C++ provides a nice alternative data type to manipulate strings, and the data type is conveniently called string. 

Solution:-


#include <iostream>

#include <string>
using namespace std;
int main()
{
  string a,b;
    cin>>a;
    cin>>b;
    int len1 = a.size();
    int len2 = b.size();
    cout<<len1<<" "<<len2<<endl;
    cout<<a<<b<<endl;
    char c;
    c=a[0];
    a[0]=b[0];
    b[0]=c;
    cout<<a<<" "<<b;
    return 0;
}

Output :-



Hacker Rank Solution Program In C++ For " Strings "



Hacker Rank Solution Program In C++ For " Strings "

No comments:
Write comments

Recommended Posts × +