You are on page 1of 2

# Write a c++ code to concatenate two strings (specifically your own first name

and last name) and display.

#include <iostream>
using namespace std;

int main()
{
string s1, s2, result;

cout << "Enter string s1: ";


getline (cin, s1);

cout << "Enter string s2: ";


getline (cin, s2);

result = s1 + s2;

cout << "Resultant String = "<< result;

return 0;
}

# Write a c++ code to print multiple objects using various manipulators.

#include <iostream>
#include <istream>
#include <sstream>
#include <string>
  
using namespace std;
  
int main()
{
    istringstream str("Programmer");
    string line;
    getline(str >> std::ws, line);
  
    cout << line << endl;
    cout << "only a test" << flush;
  
    cout << "\na";
  
    cout << "b" << ends;
    cout << "c" << endl;
  
    return 0;
}

You might also like