An acronym is a word formed from the initial letters of words in a set phrase. Write a program whose input is a phrase and whose output is an acronym of the input. If a word begins with a lower case letter, don't include that letter in the acronym. Assume there will be at least one upper case letter in the input. Ex: If the input is: Institute of Electrical and Electronics Engineers the output should is: IEEE Your program must define and call a function thats returns the acronym created for the given userPhrase.string CreateAcronym(string userPhrase) #include <iostream>#include <string>#include <cctype>using namespace std; string CreateAcronym(string userPhrase); int main() {while (true){string userPhrase;getline(cin, userPhrase); if (userPhrase == "") {break; }cout << createAcronym << endl;}return 0;}string createAcronym( const string & userPhrase ) {string acronym;bool use_next = true; for ( char c : userPhrase ){bool space = isspace(c);if ( use_next && !space ) acronym += c;use_next = space;}return acronym; } Please help me with this problem using c++.
An acronym is a word formed from the initial letters of words in a set phrase. Write a
Ex: If the input is:
Institute of Electrical and Electronics Engineers
the output should is:
IEEE
Your program must define and call a function thats returns the acronym created for the given userPhrase.
string CreateAcronym(string userPhrase)
#include <iostream>
#include <string>
#include <cctype>
using namespace std;
string CreateAcronym(string userPhrase);
int main() {
while (true)
{
string userPhrase;
getline(cin, userPhrase);
if (userPhrase == "")
{
break;
}
cout << createAcronym << endl;
}
return 0;
}
string createAcronym( const string & userPhrase )
{
string acronym;
bool use_next = true;
for ( char c : userPhrase )
{
bool space = isspace(c);
if ( use_next && !space ) acronym += c;
use_next = space;
}
return acronym;
}
Please help me with this problem using c++.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images