Question

Write a program that reads an integer, a list of words, and a character.

13.14 LAB: Contains the character

Write a program that reads an integer, a list of words, and a character. The integer signifies how many words are in the list. The output of the program is every word in the list that contains the character at least once. Assume at least one word in the list will contain the given character.

Ex: If the input is:

4 hello zoo sleep drizzle z

then the output is:

zoo
drizzle

In c++ 

0 0
Add a comment Improve this question Transcribed image text
✔ Recommended Answer
Answer #1

#include
#include
using namespace std;

int main() {
   int n;
   string str;
   cin>>n;
   char ch;
   string arr[n];
   for(int i=0;i    cin>>arr[i];
   cin>>ch;
   for(int i=0;i    {
      str=arr[i];
      for(int j=0;str[j]!='\0';j++)
      {
         if(str[j]==ch)
         {
         cout<          break;
         }
      }
   }
   return 0;
}

OUTPUT:-

Add a comment
Know the answer?
Add Answer to:
Write a program that reads an integer, a list of words, and a character.
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT