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 are computer virus ? Explain in detail.In your answer include symptoms and prevention (3each)
Elenna [48]

Answer:

Explanation:

A computer virus is a form of malicious software that piggybacks onto legitimate application code in order to spread and reproduce itself.

Like other types of malware, a virus is deployed by attackers to damage or take control of a computer. Its name comes from the method by which it infects its targets. A biological virus like HIV or the flu cannot reproduce on its own; it needs to hijack a cell to do that work for it, wreaking havoc on the infected organism in the process. Similarly, a computer virus isn't itself a standalone program. It's a code snippet that inserts itself into some other application. When that application runs, it executes the virus code, with results that range from the irritating to the disastrous.

Computer virus symptoms

How can you tell if a virus has slipped past your defenses? With some exceptions, like ransomware, viruses are not keen to alert you that they've compromised your computer. Just as a biological virus wants to keep its host alive so it can continue to use it as a vehicle to reproduce and spread, so too does a computer virus attempt to do its damage in the background while your computer still limps along. But there are ways to tell that you've been infected. Norton has a good list; symptoms include:

Unusually slow performance

Frequent crashes

Unknown or unfamiliar programs that start up when you turn on your computer

Mass emails being sent from your email account

Changes to your homepage or passwords

7 0
3 years ago
The ability for a protocol or program to determine that something went wrong is known as_________.
777dan777 [17]

Answer:

The correct answer to the following question will be Error-detection.

Explanation:

Error-detection: The detection of errors caused during the transmission from the transmitter to the receiver by damage and other noises, known as Error-detection. This error-detection has the ability to resolute if something went wrong and if any error occurs in the program.

There are mainly three types of error-detection, these types can be followed:

  • Automatic Repeat Request (ARQ)
  • Forward Error Correction
  • Hybrid Schemes

There are two methods for error-detection, such as:

  • Single parity check
  • Two-dimensional parity check

4 0
3 years ago
If you aren’t familiar with the idea of a leap year, read “Why Is There a Leap Day?” before continuing with the lab.
Zinaida [17]

The correct debugged code is attached below

<h3>What is a leap year </h3>

A leap year is a year with 366 days and this year occurs once every 4 years. The debugged code line of code of the program written, is as attached below. because the line of code in the question lacks some functions and symbols

Hence we can conclude that the correct debugged code is attached below.

Learn more about Python coding : brainly.com/question/16397886

#SPJ1

6 0
1 year ago
A company monitors the performance of all web servers using WMI. A network administrator informs the security engineer that web
Virty [35]

Answer:

The correct answer to the following question is option A). Install a HIPS on the web servers

Explanation:

HIPS stands for Host-Based Intrusion Prevention System or Host Prevention System.

HIPS is the program or system which protects your computer system against virus and the other malware and it also protects from unknown and known malicious attacks.

6 0
3 years ago
And, Or, Not are examples of:
yanalaym [24]
Boolean operators it is
all the best
5 0
3 years ago
Other questions:
  • Which of the following is a template definition?
    5·1 answer
  • Which network type connects each computer and device to a central device?
    5·1 answer
  • ____ is typically used with lans that have a star topology and can be used in conjunction with twisted-pair, coaxial, or fiber-o
    12·1 answer
  • Why do some people think the global<br> economy is good for the United States?
    10·1 answer
  • A specialized security administrator responsible for performing systems development life cycle (SDLC) activities in the developm
    11·1 answer
  • Please help me willgive u brainliest​
    14·1 answer
  • Which of the following is NOT a file format used for word processing documents? A. .ppt B. .rtf C. .doc D. .odt
    5·1 answer
  • What were the names of Henry VIII's six wives?
    9·2 answers
  • What does business informWhat does business information management do?
    12·1 answer
  • You are given a list of N integers . find the largest sum of a continuous sequence from the given list
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!