Answers
IN C++ !!
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main()
{
string userInput;
vector<string> words;
cout << endl << "Enter words (end to quit): " << endl;
do
{
cin >> userInput;
if(userInput.compare("end") == 0)
break;
else
{
words.push_back(userInput);
}
}while(userInput.compare("end") != 0);
// count the number of words that start with 'T' or 't'
int countT = 0;
for(int i = 0; i < words.size(); i++)
{
if(words[i][0] == 'T' || words[i][0] == 't')
countT++;
}
cout << endl << "Number of words starting with T/t = " << countT << endl;
// count the number of words that start with 'E' or 'e'
int countE = 0;
for(int i = 0; i < words.size(); i++)
{
if(words[i][0] == 'E' || words[i][0] == 'e')
countE++;
}
cout << endl << "Number of words starting with E/e = " << countE << endl;
// find the shortest word and the number of characters in it
vector<int> wordLength;
int index = 0;
for(int i = 0; i < words.size(); i++)
{
wordLength.push_back(words[i].length());
}
int min = wordLength[0];
for(int i = 0; i < wordLength.size(); i++)
{
if(wordLength[i] < min)
{
min = wordLength[i];
index = i;
}
}
cout << endl << "The shortest word is \"" << words[index] << "\" with " << min << " characters." << endl;
return 0;
}
******************************************************************** SCREENSHOT *******************************************************