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
emmasim [6.3K]
3 years ago
5

Write a program in main.c that reads the file lorum.txt and counts the number of characters on each line. Your program should cr

eate a file named count.txt. The contents of count.txt will contain the character count you computed for each line in lorum.txt. For each line in lorum.txt, your count.txt file must contain a line in the following format: linenumber: number_of_characters The character count for a line should not include the "newline character" (\n).
Computers and Technology
1 answer:
Aneli [31]3 years ago
4 0

Answer:

A C programming language was used to write a file lorum.txt and counts the number of characters on each line.

Explanation:

Raw_Code :

#include<stdio.h>

int main(){

  FILE *read,*write;       //creating file pointers

  int line=1,count=0;

  char ch;

  read = fopen("lorum.txt","r");   //opening files to read and write

  write = fopen("count.txt","w");

  while((ch = getc(read))!=EOF){       //reading lines until end of the file

      if(ch == '\n'){                   //if new line character encountred

          fprintf(write,"%d: %d\n",line,count);       //Then printing count of that line to file  

          line++;                       //incrementing the count of lines

          count = 0;                   //making characters count to 0

      }

      else{

          count++;           //if it is not new line character then increasing character count

      }

  }

  fprintf(write,"%d: %d",line,count);   //writing last lines count to count.txt

  fclose(read);

  fclose(write);

  return 0;

}

You might be interested in
An electronic spreadsheet is a type of<br> archive.<br> database.<br> document.<br> periodical.
zhenek [66]

Answer:

The answer is "database"

Explanation:

The spreadsheet is an application program, that is used to organized, analysis, and store data in tabular format. It is also used to import data and provide a database in programming that is used to store data and other option is not correct that can be described as follows:

  • Archive uses VBA that stands for "Visual Basic for Applications", it is used to store data in an archive file, that's why it is not correct.
  • Document is a file that is used to store data, that's why it is not correct.
  • Periodical use graph and bar charts to display data graphically, that's why it is not correct.

7 0
3 years ago
Read 2 more answers
The procedure call mystery(38) will yield which output? __________ a) 0 12 b) 12 0 c) 1 1 0 2 d) 1 1 1 1 e) 2 0 1 1 public void
Ivan

Answer:

Option b is the correct answer for the above question.

Explanation:

  • The mystery function is a recursive function that calls for the two times when the user passes 38 on the argument.
  • The first value is 38 and the second value is 2 for which that function is called.
  • When the value 38 is passed, then again 2 is passed because of the "mystery (n % 3);" statement.
  • This statement holds by the if condition which gives the true when the argument value is greater than 2.
  • Hence for the 2 value the if condition will not true and the function is not called again.
  • Then the 38/3 and 2/3 are printed whose value is 12 0, but it will print 0 12 because of the recursive function.
  • Hence option b is the correct answer while the other is not because other options does not states the output of this program.
3 0
3 years ago
The term packet is used fairly generically to refer to protocol data unit (PDU). There are PDU equivalent names in the different
Westkost [7]

Answer:

Bits

Explanation:

The protocol data unit is the representative unit of data in the OSI layer of a network. The OSI system has seven layers.

The physical layer is the first layer of the system and the protocol data unit is represented as bits of data.

Note that the term packet is the PDU for data in the network layer of the OSI network system.

4 0
3 years ago
What is operating system​
iren [92.7K]

Answer:

It's simply a software that runs a computer's basic tasks, or functions, such as scheduling, running applications, and controlling peripherals.

3 0
3 years ago
Read 2 more answers
You should check your battery ___________. Every week Never Every six months Every 30,00 miles
vova2212 [387]

The answer is Every six months

A battery acts as the brain of a car and is used to power almost everything. It can last up to five years. However, this lifespan will depend on how well the battery is maintained and the type of weather conditions you live in. Aim to check your car battery at least twice a year. Actually, it is best to check your battery regularly and not to wait for your mechanic to test your battery during routine servicing.

5 0
4 years ago
Read 2 more answers
Other questions:
  • Which fingers should you use to type the reach keys?
    12·1 answer
  • Technology offers a variety of rich opportunities available to teachers and students. According to Inan and Lowther (2010), ther
    6·1 answer
  • Help me on this question
    14·1 answer
  • When you perform an in-place upgrade to windows 8.1 from windows 7, what will be names of the “windows” folders in windows 7 and
    5·1 answer
  • While doing research on the Internet, what kind of website should you avoid because the information may be biased?
    11·1 answer
  • Fill in the blanks. The ________________ donut chart shows the distribution across your website’s pages by the number of clicks
    14·1 answer
  • Will give brainliest!!<br> (Question 3)
    12·2 answers
  • before Katie turns in the paper she typed she wants a peer to review it and give her feedback Katie uses her all in one printer
    10·1 answer
  • Write a method called rotate that moves the value at the front of a list of integers to the end of the list. For example, if a v
    6·1 answer
  • Running the Disk Cleanup utility is a quick way to ________. Group of answer choices defrag your hard drive remove spyware progr
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!