Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Reading from and Writing to a File C++ Objectives: To read input into a program from a file To output data from the program to

Reading from and Writing to a File

C++

Objectives:

To read input into a program from a file

To output data from the program to a file

Instructions:

Create an input file, called file1, and an output file, called file2, in the program. Read the data, 3 values at a time, from the input text file until you read the sentinel data line. Arrange the three values that have been read in order from lowest to highest, and then write the set of three numbers to the output file. Use a series of if statements to find the smallest, the middle value, and the largest. When all lines of data have been processed, close both files. Then reopen the output file (file2) as input. Read the data back in and print it to the screen. Use a while (!file2.eof()) to control this last part. You will need a preliminary read before the while (!file2.eof()) and another read before the end of the while loop.

Run:

Create a data file of the following integers in Notepad to run the program:

10 20 30

17 21 18

30 20 49

40 25 35

55 45 35

25 55 5

-1 -1 -1

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeffrey A. Hoffer Fred R. McFadden

4th Edition

0805360476, 978-0805360479

More Books

Students also viewed these Databases questions

Question

11. Are your speaking notes helpful and effective?

Answered: 1 week ago

Question

1. Who should participate and how will participants be recruited?

Answered: 1 week ago

Question

3. How would this philosophy fit in your organization?

Answered: 1 week ago

Question

How would you assess the value of an approach like this?

Answered: 1 week ago