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
There are three required elements needed to connect to the internet: hardware, web browser, and __________.
malfutka [58]

Yes the answer is D.internet service.

7 0
3 years ago
Read 2 more answers
How computer viruses spread from one computer to another​
morpeh [17]
Viruses spread when the software or documents they get attached to are transferred from one computer to another using a network, a disk, file sharing methods, or through infected e-mail attachments. Some viruses use different stealth strategies to avoid their detection from anti-virus software.
8 0
3 years ago
The divBySum method is intended to return the sum ofall the elements in the int arrayparameter arr that are divisible by the int
charle [14.2K]

Answer:

Explanation:

The following program is written in Java and creates the divBySum method using a enhanced for loop. In the picture attached below I have provided an example of the output given if called using the array provided in the question and a divisible parameter of 3.

public static int divBySum(int[] arr, int num) {

       int sum = 0;

       for (int x : arr) {

           if ((x % num) == 0) {

               sum += x;

           }

       }  

       return sum;

   }

4 0
3 years ago
Which group is not found on the sparkline tools design tab? a. format b. type c. show d. style
VashaNatasha [74]
Format sparkline tools design tab
4 0
3 years ago
Which IDEs support multiple high-level programming languages? Select all that apply.
nata0808 [166]

Answer:

eclipse, xcode, and visual studio

6 0
3 years ago
Read 2 more answers
Other questions:
  • You discover memory is corrupted, what would be an indication of a software vs. a hardware issue?
    5·1 answer
  • Which of the following were input devices for early portable computers?
    6·1 answer
  • A stack queue can be implemented as a circular array stack dynamic linked list dynamic vector none of these
    5·1 answer
  • A researcher wants to do a web-based survey of college students to collect information about their sexual behavior and drug use.
    7·1 answer
  • What device is used to transmit what is effectively a type of Morse code between stations?
    11·1 answer
  • A posting error is:
    8·1 answer
  • In many UNIX/Linux data and configuration files are "fields". Sometimes these fields are separated by:
    13·1 answer
  • Using simplified language and numbers, using large font type with more spacing between questions, and having students record ans
    9·1 answer
  • You are critiquing a logo design that one of your coworkers proposed. Your sense is that the individual elements of the design a
    10·1 answer
  • Which type of work would be a good candidate for improvement through automation?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!