Levels Tought:
Elementary,Middle School,High School,College,University,PHD
Teaching Since: | Apr 2017 |
Last Sign in: | 10 Weeks Ago, 2 Days Ago |
Questions Answered: | 4870 |
Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
++ Programming
Program 1
Write a program that carries out the following tasks:
Open a file with the name hello.txt.
Store the message “Hello, World!” in the file.
Close the file.
Open the same file again.
Read the message into a string variable and print it.
Program 2
Write a program that reads each line in a file, reverses its characters, and writes the resulting line to another file. Suppose the user specifies input.txt and output.txt when prompted for the file names, and input.txt contains the lines
Mary had a little lamb
Its fleece was white as snow
And everywhere that Mary went
the lamb was sure to go.
After the program is finished, output.txt should contain
bmal elttil a dah yraM
wons sa etihw saw eceelf stI
tnew yraM taht erehwyreve dnA
.og ot erus saw bmal ehT
Program 3
Write a program that reads each line in a file, reverses its characters, and writes the resulting line to the same file. Use the following pseudocode:
While the end of the file has not been reached
pos1 = current get position
Read a line.
If the line was successfully read
pos2 = current get position
Set put position to pos1.
Write the reversed line.
Set get position to pos2.