0% found this document useful (0 votes)
2 views2 pages

String 1

This C++ program takes a user input string, calculates its length, and reverses it. It then concatenates the reversed string with a predefined string 'Hello World', counts the number of words in the original string, and converts the concatenated string to lowercase. Finally, it outputs the results including the length, reversed string, concatenated string, and word count.

Uploaded by

islamicreels304
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views2 pages

String 1

This C++ program takes a user input string, calculates its length, and reverses it. It then concatenates the reversed string with a predefined string 'Hello World', counts the number of words in the original string, and converts the concatenated string to lowercase. Finally, it outputs the results including the length, reversed string, concatenated string, and word count.

Uploaded by

islamicreels304
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

#include<iostream>

#include<string>

#include<cctype>

#include<algorithm>

using namespace std;

int main()

string str; string str1 = " Hello World";string str3;

cout << "Enter value for str: ";

getline(cin, str);

int length = [Link]();

cout << "The Lenght of the string is: " << length << endl;

string strRev = str;

reverse([Link](), [Link]());

cout << "Reverse Sring is: " << str << endl;

str3 = strRev + str1;

cout << "String after concatenation is: " << str3 << endl;

int count = 0;

for (int i = 0; i<[Link]();i++)

if (str[i] == ' ')

count++;

}
cout << "Number of words in the string are: " << count+1 <<
endl;

transform([Link](), [Link](), [Link](), tolower);

cout << str3;

return 0;

You might also like