Preview

Programming Language and File

Satisfactory Essays
Open Document
Open Document
544 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Programming Language and File
Randi Reynolds
Chapter 10
PT1420
True or False
1) When working with a sequential access file, you can jump directly to any piece of data in the file without reading the data that comes before it.
False
2) In most languages, when you open an output file and that file already exists on the disk, the contents of the existing file will be erased.
True
4) The purpose of an EOF marker is to indicate where a field ends. Files typically contain several EOF markers. False
5) When an input file is opened, its read position is initially set to the first item in the file. True
Algorythm Workbench
1) Design a program that opens an output file with an external name my_name.dat, writes your name to the file, and then closes the file.

Declare OutputFile myFile

//Declare the variable to hold values
//that will be read from file
Declare String name

//Open a file named_.dat on the disk
Open myFile”Your Name”

//Close the file
Close myFile
2) 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, displays the name on the screen, and then close the file. Decalare InputFile myName Declare string name Open myName”myName.dat”

Display “Your name is: ”
While Not eof (myName)
Read myName name
Display name
End while

Close my name
3) Design an algorithm that does the following: Opens an output file with the external name number_list.dat, uses a loop to write the numbers 1 through 100 to the file and then closes the file.

Declare OutputFile numberlist Declare interger i Open numberList “number_list.dat”

For I = 1 To 100
Write myFile i
Next i
End For

Close numberList
4) Design an algorithm that does the following: Opens the number_list.dat file that was created by the algorithm created in question 3, reads all of the numbers from the file. Declare InputFile numberList Declare integer i Open numberList “number_list.dat” Display “Here are the numbers: “ While NOT eof (numberList) Read

You May Also Find These Documents Helpful