Name this program missing.c- This program\'s input is a series of words. All wor
ID: 3870661 • Letter: N
Question
Name this program missing.c- This program's input is a series of words. All words consist of only lower- case letters (a - z), no upper-case letters or digits or punctuation or other special symbols. The program reads until end-of-file, and then prints out the lower-case letters that were not seen in the input. Two executions of the program are shown below Enter your input the quick brown fox jumps over the lazy oid dog Missing letters: Enter your input roll tide Missing letters: a bc fgh j k m n p qsu v w x Y z Hints: Use an array of 26 elements to store the number of times you have seen the characters 'a' through 'z Initialize that array to zeroes, and then increment a given location when you see that letter Recall that lowercase letters are ASCII 97 (a) through ASCII 122 (z). If you subtract 97 from a given character, you get a value in the range of 0 to 25.Explanation / Answer
#include <iostream>
using namespace std;
const int MAX_ALPHA = 26;
string characterMissing(string strObj);
int main()
{
string strObj = "The quick brown fox jumps "
"over the dog";
cout << characterMissing(strObj);
return 0;
}
string characterMissing(string strObj)
{
bool current[MAX_ALPHA] = {false};
for (int iObj=0; iObj<strObj.length(); iObj++)
{
if (strObj[iObj] >= 'a' && strObj[iObj] <= 'z')
current[strObj[iObj]-'a'] = true;
else if (strObj[iObj] >= 'A' && strObj[iObj] <= 'Z')
current[strObj[iObj]-'A'] = true;
}
string result = "";
for (int iObj=0; iObj<MAX_ALPHA; iObj++)
if (current[iObj] == false)
result.push_back((char)(iObj+'a'));
return result;
}
Output:
alyz
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.