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
faltersainse [42]
3 years ago
15

Counting the character occurrences in a file

Computers and Technology
1 answer:
Katena32 [7]3 years ago
5 0

Answer:

hope this helps!

Explanation:

#include <iostream>

#include <fstream>

using namespace std;

void print_histogram(int counter[26])

{

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

       cout << (char)(i+97) << " ";

       for(int j = 0; j < counter[i]; ++j){

           cout << (char)254;

       }

       cout << endl;

   }

}

int main()

{

   int counter[26] = {0};

   string filename = "data.txt";

   char byte = 0;

   // opens file in read mode

   ifstream input_file(filename);

   if (!input_file.is_open()) {

       cerr << "Could not open the file - '"

            << filename << "'" << endl;

       return EXIT_FAILURE; // exit if not opened

   }

   // reads every character from the file

   while(input_file.get(byte)){

       if(byte >= 97 && byte <= 122){

           ++counter[byte-97];

       }

   }

   print_histogram(counter); // required print histogram function

   return 0;

}

You might be interested in
Does Kennesaw State University have any computing ethical policy for computer usage? If so - what is it?
Svet_ta [14]

Answer:

The answer to the questions: Does Kennesaw State University have any computing ethical policy for computer usage? If so - what is it? Would be as follows:

1. Yes, Kennesaw State University, a university in Georgia, does have a computing ethical policy that regulates the proper use of the facilities and computing services within the facilities of the university and the use of computing equipment that belongs to the university. This policy is known as the KSU Computer Usage Policy.

2. As said before this policy establishes that the use of computing services are not the right of a person, but rather a privilege afforded to the students, faculty and other people who are present in the university and who may need to use its computing services. The use of the computing services would be whitin this policy as long as it stays inside the delimitations established by federal, state and University policies.

Explanation:

7 0
4 years ago
Do you trust machine learning application?
laiz [17]

Answer:

Trusting a machine learning model, in general, can be interpreted as creating a robust model which gives largely accurate results and has a high generalization ability. Classification models learn from past experience, so the robustness of a model primarily depends on the given training set

Explanation:

Hope it helps

                         Please mark as brainliest

4 0
3 years ago
Where on a computer is the operating system generally stored?
Brilliant_brown [7]

The operating system on a computer is generally stored at hard disk.

4 0
3 years ago
Real Player, Flash Player, and Shockwave are examples of
Harrizon [31]
B. Plug-ins. . . . . . . . (dots because of minimum. character thing)

7 0
4 years ago
Given a set S = {a1, a2, ..., an} of positive integers (denoting asset values), Set partitioning requires to partition S into tw
mel-nik [20]

Answer:

See the pictures attached

Explanation:

3 0
4 years ago
Other questions:
  • Preserving confidentiality, integrity, and availability of data is a restatement of the concern over interruption, modification,
    15·1 answer
  • The length of time the valve is open, expressed in degrees of crankshaft rotation, is called camshaft A. overlap.B. lobe separat
    6·1 answer
  • What is a fragment shader? Question 5 (3 marks) What is trilinear filtering?
    8·1 answer
  • Is an electronic scavenger hunt played around the world.
    7·1 answer
  • When an error occurs during the execution of a method, the method ____________ an exception?
    11·1 answer
  • COMPUTER SCIENCE:PIXELS
    5·1 answer
  • Briefly describe the software quality dilemma in your own words
    13·1 answer
  • What shoul i get, Airpods or a ps4 cooling fan ???
    7·2 answers
  • Write a Java program that prompts the user for an int n. You can assume that 1 ≤ n ≤ 9. Your program should use embedded for loo
    5·1 answer
  • List any four common hardware device​
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!