CS 101 Homework 1
Assigned Laboratory 1
Due Start of Laboratory 2
Part I
- For the purposes of this homework, authorized help is any
help received from your laboratory TAs, the instructor, or the ITC staff on the
help desk.
- First bring up the Visual C++ compiler
- Open the program
hello.cpp
that you saved on your floppy disk
from this week (or get another copy from the class website)
-
Be sure that you have filled in the required header information (name,
student ID, …, date).
- Note, this homework is pledged as follows
- On my honor as a student of the
University of Virginia, I have neither given nor received unauthorized help on
this homework
- Type this exact statement after the colon on the line labeled
//Honor
pledge:
and then type your name.
- Successfully build and run the program to be sure that it still runs. It should print the string
Hello, World five times on
five separate lines.
- Modify the program so that it displays five times Goodbye, World
- Successfully build and run the program.
- Modify the program so that it displays five times Welcome to CS 101, Homework
1
- Successfully build and run the program.
- Modify the program so that it only displays the message three times.
Although we have not discussed in class how to do this, use
your intuition and experiment.
- Successfully build and run the program
- Modify the program so that it displays the message ten times instead of
three times.
- Successfully build and run the program.
Part II
- Currently the program displays Hit enter to finish. Modify the
program so that instead displays Press the enter key to terminate the
program
- Successfully build and run the program.
- Delete your line
- cout << endl << "Press the enter key to terminate the
program" << endl;
- And replace it with
- cout << "Press the enter key to terminate the program"
<< endl;
- Successfully build and run the program and observe the formatting differences.
- Replace the line
- cout << "Welcome to CS 101, Homework 1" << endl;
- with the line
- cout << endl << "Welcome to CS 101, Homework 1"
<< endl;
- Successfully build and run the program and observe the formatting differences.
Part III
- Locate and remove the two lines
char reply;
cin.get(reply)
- Successfully build and run the program and observe the difference in the program's execution.
- Restore the two lines you just deleted
- Successfully build and run the program and observe the program and assure
yourself that it operates as it did at the end of previous step.
- Print this final version of your source code.
- Review the printout of your source code. Be sure that all required
header information is filled in, the honor pledge is typed, your name is typed
and signed beside the honor pledge, and all lines of source code are present.
- On the honor pledge line
of the printout where you have typed your name, sign your name.
- Attach the homework 1 grading criteria page to your printout by stapling
it on top of your printout. Use one staple in the upper left-hand corner.
- Turn
in your printout to your lab TA at the beginning of your next lab meeting. Late labs are not accepted.