- Save a copy of the file lab011.cpp.html which is available here. Save it as a file in your home
directory. Give the file this name: lab011.cpp. (Be
sure to give it exactly that name -- it's important.) To make a copy of
the file you just display it in the browser, copy it to the clipboard,
paste it into an editor window, and then save the window.
- Compile, link, and execute lab011.cpp. For help with this step
you may refer to the example commands under "Compiling and Linking" and
"Checking for Errors and Executing the Program" in the
"Hello World!"assignment.
Understand, however, that you must use the correct file name after
the g++ command.
- Into your copy of lab011.cpp, insert a comment after the header
comment that gives your name and the date. Rerun the
program -- in other words:
- Save the file.
- Compile and link the program again.
- Execute the program again.
Did the output change? Why or why not? Put the answer in your notes.
- Change the header comment to state the following:
Program to print part of "Don't Fence Me In"
Rerun the program (as defined above). Did the output change? Why or why
not? Put the answer in your notes.
- In the second output statement, change "And the" to "Under" and the
ellipses (three continuation dots) to a period. Rerun the program.
Describe any change in the output. Put the information in your notes.
- Add another output statement before return that displays:
Don't Fence Me In.
- Add another output statement at the begining of main that
displays the title:
Don't Fence Me In
Have the computer print a few spaces before the title and a blank line
before the words of the song.
- Add other output statements to display another verse after a blank line.
Do not retype the last line, but use your editor to make a copy of this
line from the first verse.
Let me roam in the wide
Open country that I love.
Don't Fence Me In
- By removing the proper \n for each verse, make changes so that
the computer prints the first two lines of each verse on one line with
the proper capitalization as follows:
Don't Fence Me In
Give me land, lots of land under starry skies above.
Don't fence me in.
Let me roam in the wide open country that I love.
Don't fence me in.
- Rerun the program and debug it if necessary until it is working properly.
Print the code of the program (this is called a listing) with the
command:
lp -d csok1 lab011.cpp
Above,
- lp is the print command -- lp stands for "line printer."
- The -d csok1 specifies the destination -- the set of
printers you want to print the file.
- The lab011.cpp is the name of the file you are printing.
Next make a script of a run of the program. Make the script in the
manner you did in the step entitled "Making a Record of a Program Run" in
the
"Hello World!" assignment.
Print the script with an "lp" command similar to the one illustrated
above.
Retrieve your printouts from the printer. Be careful to read and follow
the directions on the printer.
Write the names of both (all) lab team members on each printout. Your
grade on this lab assignment will be based mostly on what is on the
printouts. Bring the printouts to lecture on the due date. Give them to
me at the beginning of the class. Check
the class schedule
for the due date.