Preview

PT1420 Assign. 10

Good Essays
Open Document
Open Document
702 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
PT1420 Assign. 10
PT 1420

Unit 10 Assignment1
Short Answer Review Question
Described the three steps that must be taken when a file is used by a program.
Open the file – it creates a connection between the file and the program. Opening and output file usually creates the file on the disk and allow the program to write data to it. Opening an input file allows the program to read data from the file.
Process the file – In this step data is either written to the file (if it is an output file) or read from the file (if it is an input file).
Close the file – When the program is finished using the file, the file must be closed. Closing a file disconnects the file from the program.
Why should a program close a file when it’s finished using it?
By closing a file, any unsaved data that is held in the buffer is saved to its file. Also, when a program closes files are no longer being used; the files will not take up more of the OS’s resources than necessary.
If an existing file is opened in append mode, what happens to the file existing contents?
Appending data to a file means writing new data to the end of the data that already exist in the file. Most languages allow you to open an output file in append mode, which means: if the file already exist, it will not be erased. If the file does not exist, it will be created. And when data is written to the file, it will be written at the end of the file’s current contents.
In most languages, if a file does not exist and a program attempts to open it in append mode, what happen?
If the file does not exist, it will be created.

Algorithm Workbench
Design a program that opens an output file with the external name my_name.dat, write your name to the file, and then close the file.

Declare OutputFile myFile Open myFile "my_name.dat" Write myFile "Power" Close myFile

Design a program that opens the my_name.dat file that was created by the algorithm in question 1, reads your name from the file, display the name on the screen, and then closes the file.

You May Also Find These Documents Helpful

  • Powerful Essays

    1. The program will present a series of user screens that prompts the user for specified input.…

    • 1488 Words
    • 6 Pages
    Powerful Essays
  • Good Essays

    A user has opened a word processor, typed the numbers 123456789, and stored the document as a file called report 1. Which of the following determines, in part, what bits the computer stores in the file to represent the text typed into the report?…

    • 957 Words
    • 4 Pages
    Good Essays
  • Good Essays

    Nt1210 Chapter 1 Review

    • 1315 Words
    • 6 Pages

    6. A user file has opened a word processor, typed the numbers 123456789, and stored the document as a file called report 1. Which of the following determines, in part what bits the computer stores in the file to represent the text typed into the report.…

    • 1315 Words
    • 6 Pages
    Good Essays
  • Satisfactory Essays

    Pm3110 Lesson 4

    • 513 Words
    • 3 Pages

    A ____, used in RAID Level 2, is a coding scheme that adds extra, redundant bits to the data and is therefore able to correct single-bit errors and detect double-bit errors.…

    • 513 Words
    • 3 Pages
    Satisfactory Essays
  • Satisfactory Essays

    CHAPTER3 REVEIW

    • 527 Words
    • 3 Pages

    6. A user has opened a word processor, typed the numbers 123456789, and stored the document as a file called report1. Which of the following determine, in part, what bits the computer stores in the file to represent the text typed into the report?…

    • 527 Words
    • 3 Pages
    Satisfactory Essays
  • Satisfactory Essays

    a. You input information perhaps via a keyboard or mouse to the computer and you receive output via a monitor or printer or some such device…

    • 1636 Words
    • 7 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Unit 2 NT1430

    • 377 Words
    • 2 Pages

    3. What happens when you give the following commands if the file named done already exists? $ cp to_do done $ mv to_do done…

    • 377 Words
    • 2 Pages
    Satisfactory Essays
  • Powerful Essays

    IT/210 Appendix D

    • 453 Words
    • 4 Pages

    Up to this point, you have identified the processes the program must perform, but you have not given any consideration to exactly how the processes work together to solve the problem. At this point, you must generate a description of the processing using pseudocode, a natural language description of the processing the application must perform.…

    • 453 Words
    • 4 Pages
    Powerful Essays
  • Powerful Essays

    Pt2520 Unit 6

    • 1447 Words
    • 6 Pages

    What is data redundancy, and which characteristics of the file system can lead to it?…

    • 1447 Words
    • 6 Pages
    Powerful Essays
  • Satisfactory Essays

    Unit 1 Problem Set 1

    • 750 Words
    • 3 Pages

    3. When you copy a file to a library, Windows Explorer writes the file to the folder designated as the Open and Save as combo boxes.…

    • 750 Words
    • 3 Pages
    Satisfactory Essays
  • Powerful Essays

    11. How does Windows know which application to use to open a file when you double-click the file in Windows Explorer?…

    • 850 Words
    • 4 Pages
    Powerful Essays
  • Satisfactory Essays

    When a program starts in an object-oriented language, information is put into compartments. This is what allows the program to compute things. In this example, we’ll be taking an e-business and examining an order has been placed within said program. All of the data is put into the right compartments, but what happens when the order needs to be submitted? The program has to have the capability of taking the data from the compartments and saving it to a file that can be stored and accessed.…

    • 253 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    This can be identified as a file because it begins with a (-). The first 3 bytes of this line represent the user, which is the owner. The User in this case is (rwx), so in this file the user can read, write, and execute to the file. The second 3 bytes represent the Group. The Group in this case…

    • 1336 Words
    • 6 Pages
    Good Essays
  • Good Essays

    Uli101 quiz 4b Q A

    • 341 Words
    • 2 Pages

    4. using relative to home paths output the contents of file8 appended to a new file called file21 in your home directory…

    • 341 Words
    • 2 Pages
    Good Essays
  • Good Essays

    File Organization Notes

    • 1776 Words
    • 8 Pages

    FILE ORGANIZATION -refers to the way in which records are stored in an external file - refers to the data structures used for organizing the data.…

    • 1776 Words
    • 8 Pages
    Good Essays