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
Write 3 3 advantage and disadvantage of computer​
navik [9.2K]

Answer:

Advantages: computers don't make human error

It can be used for communication

Ease of access

Disadvantages: computers can be a distraction

Potential loss of privacy

It can limit learning and create a dependency

8 0
2 years ago
To estimate the percentage of defects in a recent manufacturing​ batch, a quality control manager at Sony selects every 14th mus
sukhopar [10]

Answer:C. Systematic Sampling

Explanation:

Systematic sampling is a type of probability sampling method in which sample members from a larger population are selected according to a random starting point but with a fixed, periodic interval. This interval, called the sampling interval, is calculated by dividing the population size by the desired sample size.

Systematic sampling involves selecting items from an ordered population using a skip or sampling interval. The use of systematic sampling is more appropriate compared to simple random sampling when a project's budget is tight and requires simplicity in execution and understanding the results of a study.

8 0
3 years ago
Why did scientists who study weather need more advanced technology? Check all that apply.
kobusy [5.1K]

Answer:

All options are correct.

Explanation:

All options apply to the question because they all need technology for development and improvement. Scientists needed to develop more technologies in order to attend all their necessities, such as anticipating weather changes, forecasting weather previously, predicting weather behaviour in different places and in one specific place, accounting for reasons and natural resources related to weather changes, and much more. Therefore, technology provides faster and more consistent data for all these informations needed, since all technology tools to study weather were developed according to their specific needs.

4 0
3 years ago
Read 2 more answers
I microwaved my phone and this Bluetooth popup won't go away and I can't connect to Bluetooth. Help. I have a Google pixel 3XL I
Kobotan [32]

Answer:  Why'd you'd Microwave your phone?

Explanation: Ok first don't do that, it can make it explode, and since you did that, it messed up something, you'll have to get it fixed or buy a new one

Hope this helps^^

7 0
3 years ago
•
Natali [406]

Answer:

ion k srry

Explanation:

3 0
3 years ago
Other questions:
  • Power point 2016 which chart element provides the boundaries of the graphic?
    6·1 answer
  • A collection of related instructions organized for a common purpose is referred to as
    6·2 answers
  • Can some one please help The term career is usually applied to a what PLEASEEEEEEEEEEEE HEEEEELLLLLPPPPP MEEEEEE
    7·1 answer
  • Describe shortly about the following Linux directories and theirpurpose,1. lib2. etc3. Boot4. Root5. home
    6·1 answer
  • Do you need to know javascript to learn python?
    8·1 answer
  • Write a program that accepts 5 number and arrange them in ascending order​
    7·1 answer
  • In the URL, what is the subdomain and what is the domain name?
    5·1 answer
  • Describe how electrons move between atoms to create electricity.
    7·2 answers
  • What is the value of creating recurring tasks?
    7·2 answers
  • Being a part of an organization or giving back to the community is which rewards of work factor?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!