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
White raven [17]
4 years ago
5

In this lab, you open a file and read input from that file in a prewritten C program. The program should read and print the name

s of flowers and whether they are grown in shade or sun. The data is stored in the input file named flowers.dat. Instructions Ensure the source code file named Flowers.cpp is open in the code editor. Declare the variables you will need. Write the C statements that will open the input file flowers.dat for reading. Write a while loop to read the input until EOF is reached. In the body of the loop, print the name of each flower and where it can be grown (sun or shade). Execute the program by clicking the Run button at the bottom of the screen.
Computers and Technology
1 answer:
Bezzdna [24]4 years ago
5 0

Answer:

#include <stdio.h>

#include <string.h>

void main( )

{

array flowerProp[2];

FILE *fp; // file pointer

char flower[255]; // creating a char array to store data

fp = fopen("flowers.dat","r");

if (fp == NULL){

   printf("File flower.dat does not exist");

   return;

}

// assuming the growing condition is next line to the flower name.

while(fscanf(fp, "%s", flower)!=EOF){

   flowerProp.push(flower);

   if (flowerProp.length == 2){

       printf("%s: %s\n ", flowerProp[0], flowerProp[1]);

       memset(flowerProp, 0,0);

   }

}    

fclose (fp );

}

Explanation:

The algorithm creates a pointer to the memory location to the file starting position, the character size is used to get a string from the file line by line. Then it opens and checks if the file exists.

If the file exists, the while gets the name and growth condition of the flower, saves it to an array, prints the name and condition, and clears the array for the next flower type in the loop.

You might be interested in
____ elements are arranged to show which tasks must be completed before subsequent dependent tasks can begin.
Masteriza [31]
The answer is Gantt Chart
5 0
4 years ago
Cell division is called:
Blizzard [7]

Answer:

Mitosis

Explanation:

6 0
3 years ago
Which of the following are true about cryptocurrency wallets?
dezoksy [38]

Answer:

Looks like it is a multiple choice question

and you didn't give any choice

5 0
3 years ago
Using Task Manager, you discover an unwanted program that is launched at startup. Of the items listed below, which ones might le
sweet-ann [11.9K]

Answer: A) - E)

Explanation: <em>A and E might be the most helpful options to your question.</em>

8 0
3 years ago
When Alice turned on her laptop this morning, the screen displayed only colorful horizontal lines. Which of the following is mos
Scilla [17]

Based on the provided information, the screen displayed only colorful horizontal lines, what is  most likely to have a problem is the video card .

This is because the video card, contain graphics processing unit .

<h3>What Is a video card?</h3>

video card can be regarded the integrated circuit which generates the video signal sent to a computer display.

Learn more about video card, at;

brainly.com/question/7828376

5 0
3 years ago
Other questions:
  • As in algebra, you can use brackets to override the order of operations Excel follows to perform formula calculations. True or f
    13·1 answer
  • An 8x16 font isstored in _________________ bytes.<br> ? 8<br> ? 16<br> ? 4<br> ? 20
    13·1 answer
  • Convert the ProjectedRaises class to an interactive application named ProjectedRaisesInteractive. Instead of assigning values to
    15·1 answer
  • PLEASE READ ( if you want ) Before i used to have over 30 brainliest and i was just trying to earn points so i could get to ace,
    9·1 answer
  • 52. An assignment statement will:
    11·2 answers
  • Which of the following defines a computer program?
    14·1 answer
  • Columns, margins and orientation can all be found on what tab?
    15·1 answer
  • How do hand tools,Farm implements and farm equipment differ from one another
    6·1 answer
  • Neview of related literature happens in two wayo (1) Traditional and
    6·1 answer
  • What are programs that are installed without the user knowing
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!