String Splitter

PHOTO EMBED

Sun Dec 12 2021 13:09:05 GMT+0000 (Coordinated Universal Time)

Saved by @abzal_nurgazy #c++

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

int main()
{
	string name, name1;
	char ch;

	cout << "Enter any sentence" << endl;    // printing the middle letter 
	getline(cin, name);
	ch = name[name.length()/2];
	cout << "The middle letter in the sentence is " << ch << endl;

	for (int i = 0; i <= (name.length() / 2)-1; i++)    // printing the first half of the sentence
	{
		cout << name[i];
	}
	cout << "\nThe second half " << endl;

	for (int i = (name.length() / 2 )+1; i <= name.length(); i++)    // printing the second half of the sentence
	{
		cout << name[i];
	}


	return 0;
}
content_copyCOPY