1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
frutty [35]
3 years ago
8

c++ Write a program that reads a list of words. Then, the program outputs those words and their frequencies. The input begins wi

th an integer indicating the number of words that follow. Assume that the list will always contain less than 20 words.
Computers and Technology
1 answer:
Margaret [11]3 years ago
4 0

Answer:

The following are the program in the C++ Programming Language:

#include <iostream> //header file

#include <string>  //header file

#include <vector>  //header file

//name space

using namespace std;

//main function

int main() {

  vector<string> word; //set variable

  vector<int> c;  //set variable

  int s, counts = 0; //set variable

  string strng;  //set variable

  cout<<"Enter the size of string: "; //print message

  cin >> s; //get input

  cout<<"Enter the string: "; //print message

  for(int i = 0; i < s; ++i) {  //set for loop

     cin >> strng; //get input

     word.push_back(strng);

  }

  for(int i = 0; i < s; ++i) { //set for loop

         counts = 0;

         for(int j = 0;j<word.size();j++){ //set for loop

       if(word[j] == word[i]){ //set if statement

          counts++; //increament in counts

       }        

     }

      c.push_back(counts);

  }

  for(int i = 0; i < s; ++i) {

      cout << word[i] << " " << c[i] << endl;//print result

  }

  return 0;

}

<u>Output</u>:

Enter the size of string: 2

Enter the string: hello  sir

hello 1

sir 1

Explanation:

Here, we define three header files <iostream>, <String>, <vector> and namespace "std" after that we define main() method inside it.

  • Then, we set two vector type variables first one is string variable "word" and the second one is integer variable "c".
  • Then we set two integer variable "s" and "counts" and variable "counts" assign to 0.
  • Then, we get input from the user in variable "s" for the length of the loop.
  • Then, we set for the loop inside it, we get input in the variable "strng" from the user.
  • Then, we set the for loop for count the string repetition if any word comes again in the string then the value of count will increase.
  • Finally, we set for a loop to print the result.
You might be interested in
What is the password based off of the clues
nevsk [136]

Answer:

i would say Plane, if not then Plane then the person's birthdate.

Explanation:

3 0
2 years ago
Type the correct answer in the box. Spell all words correctly.
erica [24]

Answer:

Router

Explanation:

Routers have something called a WAN link, which can be used to connect 2 local area networks

7 0
3 years ago
The ____ algorithm tries to extend a partial solution toward completion
Fittoniya [83]

Answer: Backtracking

Explanation:

Backtracking algorithm approaches a solution in a recursive fashion whereby it tries to build answers and modify them in time intervals as we progress through the solution. One such backtracking algorithm is the N Queen problem whereby we place N Queen in a chessboard of size NxN such that no two queens attack each other. So we place a queen and backtrack if there is a possibility that the queen is under attack from other queen. This process continues with time and thereby it tends to extend a partial solution towards the completion.

8 0
3 years ago
DOC
9966 [12]
FTP used to transfer files
AND used to narrow down the search results
HTTP used to access the web
SMTP used to send mail

i hope this helped! if so, please mark brainliest!
5 0
3 years ago
A new program has been developed to increase students' speed and accuracy in doing simple arithmetic computations. You have been
Elanso [62]
This doesn't really tell me what I'm supposed to awnser
3 0
3 years ago
Other questions:
  • In which of selye's stages in death a possible outcome?
    5·1 answer
  • Java provides a(n) ____ class, which contains many useful methods for manipulating arrays.
    5·1 answer
  • sara has just started using the Internet. She would like to be more efficient . In 3-4, give sara some advice about how to be mo
    5·1 answer
  • The introduction of new information technology has a: A. dampening effect on the discourse of business ethics. B. waterfall effe
    14·1 answer
  • Which of the following is NOT areserved word in Java?intpublicstaticnum
    9·1 answer
  • Write a Python3 program to check if 3 user entered points on the coordinate plane creates a triangle or not. Your program needs
    12·1 answer
  • If a folder exists on an NTFS partition, which permission is needed by a user who needs to set security permissions on the folde
    11·1 answer
  • Why does rating an incorrect answer as 1 star raise its score on brainly?
    8·2 answers
  • This is an example of what type of formula?
    13·1 answer
  • Which of the following declares an abstract method in an abstract Java class?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!