Homework #1 -- Ch. 1-3, Bronson

Assigned: Thurs, 1/12

Due: At the beginning of class, Wed, 1/17

Worth: 10 points

Objectives: In this assignment you will use the cin and cout operators.

Note: You are welcome to work together on this homework. You will probably benefit most if it is done individually, but PLEASE don’t sit in front of a computer and get frustrated. Ask a classmate (or me) for help.

Platform: All assignments will be given as if they will be done in UNIX. Frankly, I do not care if you use Windows or any other platform for development, as long as you gain basic familiarity with UNIX.

Editor: You will need to gain familiarity with some text editor. Two common robust editors are vi and emacs. You may want to experiment with both, but I recommend against trying to learn both at the same time. Learning one of these editors may be frustrating at first, but in the long run will likely save you time. There are many vi and emacs tutorials online.

A good vi tutorial is at: http://bignosebird.com/docs/vi.shtml

An emacs tutorial is at: http://www.eecs.wsu.edu/web_main/userman/node40.html

Tip: Don’t try to learn too many editor commands at first. Learn a few, and once you are used to those, add a few more. Also, you will not be tested on an editor in class; ultimately which editor to use is up to you.

A simpler editor is pico; just type pico filename at the UNIX prompt. The commands are at the bottom of the screen. For example, Ctrl-O is "WriteOut" (or Save) and Ctrl-X exits.

1. Choose one of your favorite words. Write a program which displays:

My favorite word is chipmunk.

(Substituting, of course, your favorite word. Note: If your favorite word would make my grandmother blush, please choose another word!!)

 

 

 

2. Store the variable PI as a constant equal to 3.1416. Input an integer, and then display the difference between PI and the inputted number.

Input an integer: 3

The difference between PI and your number is: 0.1416

What to turn in: Each person should turn in the code for each problem (stapled if necessary). Make sure your name is at the top. I will not be executing your code. Also, no comments are necessary for this assignment.

One way to print in Sitterson is to type:

lpr -Phplj019 filename

Where lpr is the print command

-P specifies the printer (in this case the HP Laser Jet in Room 019… If you use a different printer, make you specify it correctly!)

For more printing info, in UNIX type howto print