Question

In: Other

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++ 

Solutions

Expert Solution

#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:-


Related Solutions

In c++ Write a program that reads a string consisting of a positive integer or a...
In c++ Write a program that reads a string consisting of a positive integer or a positive decimal number and converts the number to the numeric format. If the string consists of a decimal number, the program must use a stack to convert the decimal number to the numeric format. Use the STL stack
Lab 5 a) Write a program that reads in an unsigned integer K and sums the...
Lab 5 a) Write a program that reads in an unsigned integer K and sums the first K many integers that are divisible by 7. You should output the sum on a formatted manner b)Consider the following diamond it is an 11 by 11 diamond made with * signs. Write a program that takes as input positive odd integer K (greater than or equal to three and outputs a K by K diamond made with * signs * *** *...
C program, please Write a program that reads a sequence of 10 integer inputs and prints...
C program, please Write a program that reads a sequence of 10 integer inputs and prints the smallest and largest of the inputs and the number of even and odd inputs. for a beginner please, you could use a while loop,if-else,
*Java program* Use while loop 1.) Write a program that reads an integer, and then prints...
*Java program* Use while loop 1.) Write a program that reads an integer, and then prints the sum of the even and odd integers. 2.) Write program to calculate the sum of the following series where in is input by user. (1/1 + 1/2 + 1/3 +..... 1/n)
Write a Java program that reads a list of integers into an array. The program should...
Write a Java program that reads a list of integers into an array. The program should read this array from the file “input.txt”. You may assume that there are fewer than 50 entries in the array. Your program determines how many entries there are. The output is a two-column list. The first column is the list of the distinct array elements; the second column is the number of occurrences of each element. The list should be sorted on entries in...
C++ 10.15: Character Analysis Write a program that reads the contents of a file named text.txt...
C++ 10.15: Character Analysis Write a program that reads the contents of a file named text.txt and determines the following: The number of uppercase letters in the file The number of lowercase letters in the file The number of digits in the file Prompts And Output Labels. There are no prompts-- nothing is read from standard in, just from the file text.txt. Each of the numbers calculated is displayed on a separate line on standard output, preceded by the following...
In C++, The following program reads one character from the keyboard and will display the character...
In C++, The following program reads one character from the keyboard and will display the character in uppercase if it is lowercase and does the opposite when the character is in uppercase. If the character is a digit, it displays a message with the digit. Modify the program below such that if one of the whitespaces is entered, it displays a message and tells what the character was. // This program reads one character from the keyboard and will //...
● Write a program that reads words from a text file and displays all the words...
● Write a program that reads words from a text file and displays all the words (duplicates allowed) in ascending alphabetical order. The words must start with a letter. Must use ArrayList. MY CODE IS INCORRECT PLEASE HELP THE TEXT FILE CONTAINS THESE WORDS IN THIS FORMAT: drunk topography microwave accession impressionist cascade payout schooner relationship reprint drunk impressionist schooner THE WORDS MUST BE PRINTED ON THE ECLIPSE CONSOLE BUT PRINTED OUT ON A TEXT FILE IN ALPHABETICAL ASCENDING ORDER...
Write a short main program that reads an integer n from standard input and prints (to...
Write a short main program that reads an integer n from standard input and prints (to standard output) n lines of * characters. The number of *’s per line should double each time, starting with 1. E.g., if n = 5, the output should be as follows: * ** **** ******** ****************
MARS: Use MASKING to convert ASCII characters to Integer Write and run a program that reads...
MARS: Use MASKING to convert ASCII characters to Integer Write and run a program that reads in a string of ASCII characters and converts them to Integer numbers stored in an array USING MASKING, not subtraction. Write a program that: 1. Inputs a 1x8 vector of single-digit integers 2. Stores them into an 8-entry 32-bit Integer array, “V”. After storing the integers in the array: 1. Read the same values using Read Integer and store them in a 32-bit integer...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT