daily pastebin goal


a guest May 16th, 2018 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 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. If the input is Institute of Electrical and Electronics Engineers, the output should be IEEE.
  2. Your program must define and call a function string CreateAcronym(string userPhrase) that returns the acronym created for the given userPhrase.
  3. Hint: Refer to the ascii table to make sure a letter is upper case.
  5. #include <iostream>
  6. #include <cmath>
  7. #include <string>
  8. #include <cctype>
  9. using namespace std;
  11. string CreateAcronym(string userPhrase){
  12.     int sze;
  13.     string acrn= "";
  14.     sze = userPhrase.size();
  15.     for(int i=0 ; i<sze; ++i){
  16.         if(userPhrase.at(i) >= 65 && userPhrase.at(i) <= 90) {
  17.             acrn = acrn + userPhrase.at(i);
  18.                     }
  19.         return acrn;
  20.     }
  21. }
  23.     int main(){
  24.         string phrase;
  25.         getline(cin,phrase);
  26.         cout << CreateAcronym(phrase);
  27.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand