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's your opinion on Pokemon​ and pixeldip
faust18 [17]

Answer:

Its a good game but an amazing show. 10/10

Explanation:

7 0
2 years ago
Which ics function records time accounting and procures needed items?
vladimir1956 [14]
It is the finance / administration function that records time accounting and procures the needed items
7 0
2 years ago
A blue line, called a ____ line, that appears when you are dragging a GUI object on a Windows Form object indicates that the obj
ser-zykov [4K]

Answer:

snap

Explanation:

The line which appears when we are dragging an object of GUI on a object of  windows Form indicates that the object that is being dragged is aligned horizontally with the object which is connected by the blue line is called a snap line.

Hence we conclude that the answer to this question is snap line.

3 0
3 years ago
For whover needed pont
podryga [215]

Answer:

Thank you have a nice day:)

8 0
2 years ago
Read 2 more answers
The term ____ refers to the use of a single unifying device that handles media, internet, entertainment, and telephone needs.Dig
Genrish500 [490]

Answer:

The answer IS digital convergence.

Explanation:

6 0
1 year ago
Other questions:
  • The Internet has made it possible for most people to order all of their clothing online. While this may be a preference for some
    5·1 answer
  • Which of the following is likely the cause of the bass from a sound system rattling the windows on your car?
    11·1 answer
  • Carly is part of a community of developers. In her free time, she works on code to improve this open-source operating system. Th
    11·1 answer
  • Summarizes statistical data ?
    11·1 answer
  • An access control system that grants users only those rights necessary for them to perform their work is operating on which secu
    6·1 answer
  • What attracts attention and adds spatial depth to a two-dimensional design.
    9·1 answer
  • Which page in a web site do viewers usually see first?
    15·1 answer
  • a machine needs a minimum of 100 sec to sort 1000 names by quicksort what is the approximate worst case time needed to sort 100
    13·1 answer
  • Which one is the result of the output given by a compute
    15·2 answers
  • What is the following file format called? inv_nbr, inv_name, inv_cost 876521,battery,45.00
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!