Home >  T.A >  cs10 ( Fall 2001 ) >  Lab 5

  CS10 Sec#24 : Topics covererd in Lab #5
T.A: Demetris Zeinalipour
(Fall 2001)

Print this Page   
 [  Academic Dishonesty Policy  ::   Style Considerations  ::   Style Examples  ::   Statements Table  ::   Exercise #5 ]



Academic Dishonesty Policy

If you haven't attended last Lab please sign the Cheating Policy Sheet.
Top


Style Considerations
(See “C++ Style Guidelines” handout posted on Pr.Kelsey web page.)
  1. Use blank lines to separate set of related instructions.
  2. Liberally use clear and helpful comments.
  3. Make comments stand out - end of line (lined up) or blank line above comment.
  4. Type each statement on a separate line.
  5. Avoid running a statement over multiple lines.
  6. Avoid line splicing (line too long)
  7. Indent lines after a curly brace by the same amount until the end curly brace.
  8. Use whitespace in typing statements (cout<<"Hello all"; cout  <<  “Hello all”;)
Top


Overview of Style with examples

Example 1   Example 2   Example 3  
Top


Loops - Statements Reference Table

Top


Lab 5 Assignment-Exercise

Write a program that reads in characters until the user enters the correct two-character sequence as a password. The password is cs. This password is used to open a door, let the user know when the door is open.

For example, the following sequences should all open the door:

cs

imacsmajor

ccs


But these sequences would not open the door and would require the user to keep inputting characters.

cas

sc

You do not need to prompt for each character one at a time. Your program should simply keep reading characters until the proper password has been entered. The program will just wait for the user to type in more characters if the password has not been entered correctly yet. If the password was entered correctly, output a statement saying the door has been opened and then the program will be finished.

Notice: Be sure to put all your information (login, lab section, …) at the top of your program. Your lab programs DO NOT get turned in electronically. I will come around and check you off individually.

Top