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
katrin [286]
4 years ago
11

Write a main function to do the following: Create a string that can hold up to 30 characters. Create an array of 10 strings with

room for 60 characters plus the null byte. Prompt the user and read the name of an input file into your string. Open the file for input. Call your function to read from the file into the array. Read into all 10 strings. Call your function to remove the newlines at the end of all of the strings. Call your function to print all of the strings. Print the smallest string. Change all of the strings to uppercase. Print all of the strings again.

Computers and Technology
1 answer:
masha68 [24]4 years ago
6 0

Answer:

Check the explanation

Explanation:

#// do comment if any problem arises

//code

#include <stdio.h>

#include <ctype.h>

#include <string.h>

#include <stdlib.h>

void read(FILE *input, char array[10][61])

{

   // read all 10 strings

   for (int i = 0; i < 10; i++)

       fgets(array[i], 60, input);

}

void remove_newline(char array[10][61])

{

   for (int i = 0; i < 10; i++)

   {

       array[i][strlen(array[i]) - 1] = '\0';

   }

}

void smallest(char array[10][61])

{

   int s = 0;

   for (int i = 1; i < 10; i++)

   {

       if (strlen(array[s]) > strlen(array[i]))

           s = i;

   }

   printf("\nSmallest strnig: %s\n", array[s]);

}

void upper(char array[10][61])

{

   for (int i = 0; i < 10; i++)

   {

       int n = strlen(array[i]);

       for (int j = 0; j < n; j++)

       {

           array[i][j] = toupper(array[i][j]);

       }

   }

}

int main()

{

   char filename[30];

   // array of 10 strings

   char array[10][61];

   printf("Enter filename: ");

   gets(filename);

   // open file

   FILE *input = fopen(filename, "r");

   // read into array

   read(input, array);

   // close file

   fclose(input);

   // remove newline

   remove_newline(array);

   // print

   printf("Contents of file:\n");

   for (int i = 0; i < 10; i++)

       printf("%s\n", array[i]);

   // print smallest string

   smallest(array);

   // uppercase

   upper(array);

   // print again

   printf("\nContents of file after converting to uppercase:\n");

   for (int i = 0; i < 10; i++)

       printf("%s\n", array[i]);

}

kindly check the attached image below to see the Output:

You might be interested in
Suppose that a 2M x 16 main memory is built using 256kB x 8 RAM chips and memory is word addressable, how many RAM chips are nec
hoa [83]

Answer:

16 RAM chips

Explanation:

To calculate the number of RAM chips needed, we divide the total size of the main memory by the size of each RAM chip. Hence:

Number of RAM chips required = Main memory size / size of one RAM

2M = 2²¹, 16 = 2⁴, 256K = 2¹⁸, 8 = 2³

Hence:

Number of RAM chips required = (2²¹ * 2⁴) / (2¹⁸ * 2³) = 2⁴ = 16

Therefore 16 RAM chips are necessary

5 0
3 years ago
nswer the following questions concerning chapter 1:1.1 Which pair of layers are NOT peer layers?a.Transport layer in the sender
frosja888 [35]

Answer:

b.Transport layer in the sender and application layer in the receiver

Explanation:

A peer layer communication is usually used to describe the interactions of different layers among one another in the presence of system communication. If there is a single system, there will be approximately two neighboring layers such that one layer is below while the other is above. Therefore, the answer is option b.

8 0
3 years ago
Please answer this correctly what’s the answer opening modify style dialog box enables you to
Aloiza [94]
The answer is all of the above
4 0
4 years ago
In order to ensure drive health, what command should you use to search for a repair file system error
ira [324]
The chkdsk command fixes file system errors and recovers data from bad sectors to ensure system health
3 0
3 years ago
An example of an online personalized recommendation would be when:
Phoenix [80]

Answer:

A:

Explanation:

I think

6 0
3 years ago
Read 2 more answers
Other questions:
  • What is the most important reason to create a backup of your files somewhere other than your computer
    6·1 answer
  • A four year old laptop will not boot and presents error messages on the screen
    8·1 answer
  • Which layer of the osi model is mainly concerned with routing packets of data from one network card to another across a large ne
    9·1 answer
  • Under the advanced options screen, what startup option should be enabled in order to view what did and did not load during the b
    12·1 answer
  • Which of the following grinding methods is best suited to a shorter cylindrical workpiece?
    8·1 answer
  • What is the different between 32bit anf 64 bit verision​
    11·1 answer
  • Convert the following 8­bit binary numbers in two's complement format to decimal (If the number is negative, include the minus s
    5·1 answer
  • Two people can verify they are communicating with each other by using a ____________, which verifies each party's identity by be
    12·1 answer
  • Write down the pseudo code for a brute-force algorithm to compare elements in array A with elements in array B.
    6·1 answer
  • If a company saw an online photo of you playing basketball, it might try to sell
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!