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
Hoda wants to create a new presentation in PowerPoint with existing graphics and designs. What is the easiest and fastest way fo
Paul [167]

Answer: a

Explanation:

6 0
4 years ago
Smart art is considered a​
mina [271]

Explanation:

visual representation of information and ideas, and a chart is a visual illustration of numeric values or data. Basically, SmartArt graphics are designed for text and charts are designed for numbers. Use the information below to decide when to use a SmartArt graphic and when to use a chart.

4 0
3 years ago
g Write a user-defined MATLAB function for the following math function: y ( x )=(−.2 x 3 +7 x 2 )e −.3x The input to the functio
kolezko [41]

Answer:

Go to explaination for the step by step answer.

Explanation:

a)Code

function[y]=operation(x) % this function takes x as input and returns y as output

y=(-0.2*x^3+7*x^2)*exp(-0.3*x)

end

% call this function in command widow by typing operation(value of x) like shown in figure in the first attachment.

b. write a code of above function in one script window and save the code with same name as name of function that is name of script should be saved as operation.Now copy paste the below code in new script window and run the code

clc

clear all

x=-2:.1:6

n=length(x)

for i=1:1:n

a=x(i)

y(i)=operation(a)

end

plot(y,x)

xlabel('X')

ylabel('Y')

Please kindly check attachment for pictorial answers that supports the code.

4 0
3 years ago
What are the parts of word?
jolli1 [7]

Answer:

Explanation:

ASIA includes 50 countries, and it is the most populated continent, the 60% of the total population of the Earth live here.

AFRICA comprises 54 countries. It is the hottest continent and home of the world's largest desert, the Sahara, occupying the 25% of the total area of Africa.

NORTH AMERICA includes 23 countries led by the USA as the largest economy in the world.

SOUTH AMERICA comprises 12 countries. Here is located the largest forest, the Amazon rainforest, which covers 30% of the South America total area.

ANTARCTICA is the coldest continent in the world, completely covered with ice. There are no permanent inhabitants, except of scientists maintaining research stations in Antarctica.

EUROPE comprises 51 countries. It is the most developed economically continent with the European Union as the biggest economic and political union in the world.

AUSTRALIA includes 14 countries. It is the least populated continent after Antarctica, only 0.2% of the total Earth population live here.

7 0
3 years ago
If you tap or click the increase font size button too many times and make the font size too big, you can tap or click the _____
ioda
You can click the ctrl and minus  button at the same time
7 0
4 years ago
Other questions:
  • Which of the following must be included in the disaster recovery plan? Select one: a. Business functions b. Critical support fun
    12·1 answer
  • Based upon the contents of the BOOKS table, which line of the following SQL statement contains an error?
    13·1 answer
  • Use a recursion tree to determine a good asymptotic upper bound on the recurrence T(n) = 4T(n/2 + 2) + n. Use the substitution m
    5·1 answer
  • A common method of grouping security risks and security safeguards (controls) is to organize them into logical _________________
    12·1 answer
  • Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 te
    13·1 answer
  • Which of the following statements comparing debit cards to credit cards is TRUE?
    13·2 answers
  • Plz tell the answer I I'll mark u as the brainliest
    14·1 answer
  • Do you ever wonder what types of media you will be using five years from now or when you graduate from college or a training pro
    9·1 answer
  • PLEASE HELP ASAPP!!
    7·1 answer
  • What are the different types of topology?​ in details
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!