Edit this essay
only $12.90/page

Programming Language Essay Sample

Programming Language Pages
Pages: Word count: Rewriting Possibility: % ()

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 numberList i
Dislpay i
End While

Close myName
Programming Exercise’s
1) File display
Assume that a file containing a series of integers is named numbers.dat and exists on the computers disk. Design a program that displays all of the numbers in the file.
Def main():
n=1
largest= None

Num_input=int(input(“How many numbers “ + “ You have to input?”))

Numbers_file= open(‘numbers.dat’,’w’)

For count in range(1, num_input+1):
Number= float(input(‘Enter the Number #’ + str(count) +str(count) + ‘:’))

If largest is None or n > largest:
Largest= n
Print(‘The largest value inputted is ‘, largest)
Numbers_file.closed()
Main()
2) Item Counter
Assume a file containing a series of names (as strings) is named names.dat and exists on the computers’ disk. Design a program that displays the number of names that are stored in the file. (Hint: Open the file and read every string stored in it. Each time you read a string, increment a counter variable. When you’ve read all the strings from the file, the counter variable will contain the number of names stored in the file.)

Infile = Open (‘names.txt’,’r’)
Count = 0
Line = infile. readline ()
while line!= ‘’:
print (line, end=”)
count + =1
line = infile.readline ()
infile.close ()
print (“there were a total of “, count, “name(s).”)

Search For The related topics

  • language
  • numbers