STARTING OUT W/PROGRAM.LOGIC...-TEXT
STARTING OUT W/PROGRAM.LOGIC...-TEXT
5th Edition
ISBN: 2810022369454
Author: GADDIS
Publisher: PEARSON
bartleby

Videos

Textbook Question
Book Icon
Chapter 10, Problem 1MC

A file that data is written to is known as a(n)

  1. a. input file
  2. b. output file
  3. c. sequential access file
  4. d. binary file
Expert Solution & Answer
Check Mark
Program Description Answer

The file to which the data is written is known as an output file.

Hence the correct answer is option “B”.

Explanation of Solution

Output file:

  • A file where the data are written is called as “output file”. The output file is created on the disk and allows the program to write a data on it.
  • The “output file” must be accessed using the file name and must be closed after the usage of the file.
    • If the file is not closed properly, it can cause a loss of data. Because, the data that is written to a file is stored in a buffer first.
    • After closing a file, the buffer saves the contents into the disk.

Example for output file:

The following program is used to open an output file, writes a name to it and then closes it.

#Function main

def main():

#Open an outfile for writing

    outfile=open('my_name.txt','w')

#Write the name into file

    outfile.write("Tom cruise")

#Close the file

    outfile.close()

#Display statement

print('Data written to my_name.txt')

#Call the main function

main()<SAMPLE-OUTPUT>

Explanation:

The above program is used to open an output file named “my_name.txt”, and writes a name to it and then closes it:

  • In “main()” function, open a file “my_name.txt” and write a name "Tom cruise" to the file using “write()” method.
  • Close the file using “close()” method. Display the intimation message on the screen.
  • Call the “main()” function.

Explanation for the incorrect options:

Input file:

A file from which the data is read is called as input file. When a program gets input from the file, then it is called as input file.

Hence, the option “A” is wrong.

Sequential access file:

In sequential access method, the contents of the file are accessed from the beginning to the end.

Hence, the option “C” is wrong.

Binary file:

Binary file holds data that are not represented in the form of text. The executable programs are stored in the type of binary file. Due to this, the contents present in the binary file cannot be viewed with normal text editors.

Hence, the option “D” is wrong.

Sample Output

Data written to my_name.txt

Screenshot of “my_name.txt” file

STARTING OUT W/PROGRAM.LOGIC...-TEXT, Chapter 10, Problem 1MC

Want to see more full solutions like this?

Subscribe now to access step-by-step solutions to millions of textbook problems written by subject matter experts!
Students have asked these similar questions
help with this please
For the control system plot root Locus and find the D gain of stability? by Matlab Ris Kp (5+3) S+5 (s+1) +CUST s(S+2) (565+18) 5-1 5²+35+4
CIS 115 Introduction to C++ May I please have a written review expressing my gratitude for a tutor that has given me guidance throughout the computer programming course? Thank you so much!

Chapter 10 Solutions

STARTING OUT W/PROGRAM.LOGIC...-TEXT

Ch. 10.1 - Prob. 10.11CPCh. 10.1 - Prob. 10.12CPCh. 10.1 - What is a files read position? Initially, where is...Ch. 10.1 - In what mode do you open a file if you want to...Ch. 10.2 - Prob. 10.15CPCh. 10.2 - What is the purpose of the eof function?Ch. 10.2 - Is it acceptable for a program to attempt to read...Ch. 10.2 - Prob. 10.18CPCh. 10.2 - Which of the following loops would you use to read...Ch. 10.4 - Prob. 10.20CPCh. 10.4 - Prob. 10.21CPCh. 10.4 - Prob. 10.22CPCh. 10 - A file that data is written to is known as a(n) a....Ch. 10 - A file that data is read from is known as a(n) a....Ch. 10 - Before a file can be used by a program, it must be...Ch. 10 - When a program is finished using a file, it should...Ch. 10 - The contents of this type of file can be viewed in...Ch. 10 - This type of file contains data that has not been...Ch. 10 - When working with this type of file, you access...Ch. 10 - When working with this type of file, you can jump...Ch. 10 - This is a small holding section in memory that...Ch. 10 - Prob. 10MCCh. 10 - This is a character or set of characters that...Ch. 10 - This marks the location of the next item that will...Ch. 10 - When a file is opened in this mode, data will be...Ch. 10 - The expression NOT eof (myFi1e) is equivalent to...Ch. 10 - This is a single piece of data within a record. a....Ch. 10 - When working with a sequential access file, you...Ch. 10 - In most languages, when you open an output file...Ch. 10 - The process of opening a file is only necessary...Ch. 10 - Prob. 4TFCh. 10 - Prob. 5TFCh. 10 - When a file that already exists is opened in...Ch. 10 - In control break logic, the program performs some...Ch. 10 - Describe the three steps that must be taken when a...Ch. 10 - Why should a program close a file when its...Ch. 10 - What is a files read position? Where is the read...Ch. 10 - If an existing file is opened in append mode, what...Ch. 10 - In most languages, if a file does not exist and a...Ch. 10 - What is the purpose of the eof function that was...Ch. 10 - What is control break logic?Ch. 10 - Design a program that opens an output file with...Ch. 10 - Design a program that opens the my_name.dat file...Ch. 10 - Prob. 3AWCh. 10 - Design an algorithm that does the following: opens...Ch. 10 - Modify the algorithm that you designed in question...Ch. 10 - Write pseudocode that opens an output file with...Ch. 10 - Prob. 7AWCh. 10 - A file exists on the disk named students.dat. The...Ch. 10 - Why doesn't the following pseudocode module work...Ch. 10 - File Display Assume that a file containing a...Ch. 10 - Item Counter Assume that a file containing a...Ch. 10 - Sum of Numbers Assume that a file containing a...Ch. 10 - Average of Numbers Assume that a file containing a...Ch. 10 - Largest Number Assume that a file containing a...Ch. 10 - Golf Scores The Springfork Amateur Golf Club has a...Ch. 10 - Sales Report Brewster's Used Cars, Inc. employs...Ch. 10 - Lowest and Highest Gas Prices Assume that you have...Ch. 10 - Average Steps Taken A Personal Fitness Tracker is...

Additional Engineering Textbook Solutions

Find more solutions based on key concepts
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Text book image
Systems Architecture
Computer Science
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Cengage Learning
C - File I/O; Author: Tutorials Point (India) Ltd.;https://www.youtube.com/watch?v=cEfuwpbGi1k;License: Standard YouTube License, CC-BY
file handling functions in c | fprintf, fscanf, fread, fwrite |; Author: Education 4u;https://www.youtube.com/watch?v=aqeXS1bJihA;License: Standard Youtube License