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

  • Satisfactory Essays

    Nt2670 Unit 7 Lab 1

    • 402 Words
    • 2 Pages

    7. In case the file is opened another application in the future for modifying the file, such as adding more content either text, pictures, etc.…

    • 402 Words
    • 2 Pages
    Satisfactory Essays
  • 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

    It/210 Final Exam

    • 1235 Words
    • 5 Pages

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

    • 1235 Words
    • 5 Pages
    Good Essays
  • Good Essays

    Which of the following is not a feature of the file system that might be used with a hard disk drive?…

    • 957 Words
    • 4 Pages
    Good Essays
  • Good Essays

    Nt1210 Chapter 1 Review

    • 1315 Words
    • 6 Pages

    9. A student writes a report using a word processor, saving the repot in a file called my_report. The student stores the file on his laptop hard disk drive. Later, he pasts the file on a file-sharing site for a classmate to review the report. Then, he copies an updated version of the file to a flash drive to submit it to his instructor. Which of the following are some of the important features supplied by files as defined by a computer OS?…

    • 1315 Words
    • 6 Pages
    Good Essays
  • Good Essays

    9. A student writes a report using a word processor, saving the report in a file called my report. The student stores the file on his laptop hard disk drive. Later, he posts the file on a file-sharing site for a classmate to review the report. Then, he copies an updated version of the file to a flash drive to submit it to his instructor. Which of the following are some of the important features supplied by files as defined by a computer OS? (Choose three answers.)…

    • 856 Words
    • 4 Pages
    Good 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
  • 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
  • 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

    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