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
aksik [14]
3 years ago
15

Open the"stateData3.c" program and try to understand how the tokenization works. If you open the input file "stateData.txt", you

can clearly seethat a comma separates the state name and its population. The tokenizer portion of the programs separates each line into two tokens and stores them into two different arrays. You need to display the arrayelements such that each line has a state and itspopulation. Also calculate the total population of USA.Then,examine the portion of the code how it writes the array elements into a binary datafile.You need to write similar logic where it writes the array elements into a text file "stateDataOutput2.txt". Please check the syntax and usage of fprintf(); and use that here.
Engineering
1 answer:
babymother [125]3 years ago
5 0

Answer:

Kindly see explaination

Explanation:

Code

#include<stdio.h>

#include<stdlib.h>

#include<string.h>

#define size 200

int main(void)

{

int const numStates = 50;

char tempBuffer[size];

char tmp[size];

char fileName[] = "stateData.txt"; // Name of the text file (input file) which contains states and its populations

char outFile[] = "stateDataOutput1.txt"; // Output file name

// Open the input file, quit if it fails...

FILE *instream = fopen(fileName, "r");

/* Output File variable */

FILE *opstream;

if(instream == NULL) {

fprintf(stderr, "Unable to open file: %s\n", fileName);

exit(1);

}

//TODO: Open the output file in write ("w") mode

/* Opening output file in write mode */

opstream = fopen(outFile, "w");

//TODO: Read the file, line by line and write each line into the output file

//Reading data from file

while(fgets(tmp, size, instream) != NULL)

{

//Writing data to file

fputs(tmp, opstream);

}

// Close the input file

fclose(instream);

//TODO: Close the output file

/* Closing output file */

fclose(opstream);

return 0;

}

You might be interested in
A vertical piston-cylinder device initially contains 0.2 m3 of air at 20°C. The mass of the piston is such that it maintains a c
Ann [662]

Answer:

Amount of air left in the cylinder=m_{2}=0.357 Kg

The amount of heat transfer=Q=0

Explanation:

Given

Initial pressure=P1=300 KPa

Initial volume=V1=0.2m^{3}

Initial temperature=T_{1}=20 C

Final Volume=V_{2}=0.1 m^{3}

Using gas equation

m_{1}=((P_{1}*V_{1})/(R*T_{1}))

m1==(300*0.2)/(.287*293)

m1=0.714 Kg

Similarly

m2=(P2*V2)/R*T2

m2=(300*0.1)/(0.287*293)

m2=0.357 Kg

Now calculate mass of air left,where me is the mass of air left.

me=m2-m1

me=0.715-0.357

mass of air left=me=0.357 Kg

To find heat transfer we need to apply energy balance equation.

Q=(m_{e}*h_{e})+(m_{2}*h_{2})-(m_{1}*h_{1})

Where me=m1-m2

And as the temperature remains constant,hence the enthalpy also remains constant.

h1=h2=he=h

Q=(me-(m1-m2))*h

me=m1-me

Thus heat transfer=Q=0

6 0
3 years ago
Which of the following lists the steps of a process in the correct order?
Vladimir79 [104]

Answer: C. Problem identification, solution design, implementation, evaluation.

Explanation:

4 0
3 years ago
Read 2 more answers
Based on the concept that it is better to prevent falls happening in the first place, which of the following safety methods meet
alekssr [168]

Answer:fall arrest harness

Explanation:cuz it’s just right

7 0
3 years ago
A dairy in Fresno County discharges its wastewater to a circular treatment pond. The dairy wants to expand its operations, which
Strike441 [17]

Answer:

420.69 mg

Explanation:

i just did that last week

4 0
3 years ago
True or False: In a technical drawing dimensions are optional. The manufacturer can decide on their own how big or small to make
Law Incorporation [45]

Answer:

False

Explanation:

4 0
3 years ago
Other questions:
  • The number of weaving errors in a twenty-foot by ten-foot roll of carpet has a mean of 0.8 What is the probability of observing
    6·1 answer
  • CS3733: Homework/Practice 05 Suppose we would like to write a program called monitor which allows two other programs to communic
    5·1 answer
  • Which of the following are some of the problems found in city streets?
    6·1 answer
  • If the outside diameter of a pipe is 2 m, the length of a piece of insulation wrapped around it would be a)- 628 cm b)- 12.56 m.
    15·1 answer
  • A binary geothermal power plant uses geothermal water at 160°C as the heat source. The cycle operates on the simple Rankine cycl
    9·2 answers
  • This problem has been solved!
    10·1 answer
  • 2 Blocks 1 and 2 rest on rough surfaces with coefficient of frictions ¢1 and ¢2 respectively. The blocks
    12·1 answer
  • Tech A says that coolant circulates through some intake manifolds to help warm them up. Tech B says that some intake manifolds u
    13·1 answer
  • What does Enter key do?
    10·1 answer
  • which acpi power state allows a system to start where it left off, but all other components are turned off? sleeping mechanical
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!