#include<iostream>
using namespace std;
int main()
{
string Name;
cout << "Enter the full name of the university: ";
getline (cin, Name);
cout << "Your name is: " << Name;
string str = Name;
char checkCharacter = 'e';
int count = 0;
for (int i = 0; i < str.size(); i++)
{
if (str[i] == checkCharacter)
{
++ count;
}
}
cout << "\nNumber of " << checkCharacter << " = " << count<<endl;
cout <<"The last 21 characters of the string are: "<<Name.substr(Name.length() - 21) << endl;
string str1 = Name;
string str2 = "Accra";
str1.replace(0,5,str2);
cout << "String after replacement is: "<<str1<<"\n";
}
Comments
Leave a comment