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
To update a bibliography field that is not contained in a ____, right-click the bibliography, and then click Update Field on the
Helen [10]

Answer:

The answer to this question is Style.

Explanation:

This updates a bibliography:-

1.Click the bibliography. A frame pops up around it.

2.Click on the arrow present on the frame, and then click on Update.

But if we have to update a bibliography field and it is not within a style,right click on the bibliography after that click Update field on the shortcut menu.

8 0
4 years ago
Identify the problems that computer program bugs can cause. Check all that apply.
Sveta_85 [38]

Answer:

acde not b though

Explanation:

8 0
3 years ago
Read 2 more answers
What function does a mobile device’s accelerometer serve?
Masteriza [31]

Answer:

The correct answer is: <u>A.  it determines the orientation of the device</u>

Explanation:

An accelerometer is a sensor in mobile phone devices that is used to detect the orientation of the phone and then change the orientation of the content displayed on the mobile screen to adjust accordingly.

So the correct answer is:

<u>A.  it determines the orientation of the device</u>

4 0
4 years ago
Read 2 more answers
Which statement is unnecessary inside the unit test for the custom controller?
Anna [14]

Answer:

A. public ExtendedController(ApexPages.StandardController cntri) { }

Explanation:

A wizard is generally referred to as the tab sequence that contains the back button as well as the next button. It usually accepts information (i.e. data) from the inputs of users from different pages of the visualfoce as well as a variable from the previous website. The statement in option A is unnecessary for the application of the custom controller.    

5 0
4 years ago
The specific term for expediting the delivery of software by breaking a task into smaller increments is called
Ksivusya [100]
Rapid Application Development is the specific term
8 0
3 years ago
Other questions:
  • How can an installation be a tool for community building?
    9·1 answer
  • What is computer <br> What is scratch
    10·2 answers
  • Wap to input any multi digits number and display the sum of odd digits and even digits​
    5·1 answer
  • The UML models operations by listing the operation name preceded by an access modifier. A(n) ________ indicates a public operati
    7·2 answers
  • Select each item that represents what the Internet may be used for:
    9·1 answer
  • Please help! i need to answer this soon!
    13·1 answer
  • Type two statements.
    11·1 answer
  • Which argument forces a writer to return and change the input berfore resolving unicode erroe
    8·1 answer
  • What is the two’s compliment of -95,-122,-111,-57
    9·1 answer
  • Which keyboard shortcut would you press to copy cells that are selected in a spreadsheet?
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!