C++ PROGRAM STRUCTURE

Chapter 2 Homework Assignment: Solution

Chapter Questions

  1. List two rules for using identifiers
  2. List three reserved words introduced in Chapter 2
  3. Write an example of a value for the following data types:
    char, int, floating point
  4. What is the difference between a constant and a variable?
  5. All your C++programs will use the variable cout. Why?

Answers to homework reading assignment:

  1. Any of the following would be correct answers:
    a. Identifier names must begin with a letter of the alphabet or a digit.
    b. Blank spaces are not allowed in identifier names.
    c. Identifier names should be descriptive and meaningful.
    d. You cannot use reserved words as identifier names.

  2. a. cout
    b. const
    c. int

  3. a. An example of char data type would be a single letter, symbol, number
    'A'    'a'    '8'    '2'   '$'

    b. An example of int data type would be
    100    2098     8769

    c. an example of floating point data type would be a decimal number
    18.0     127.5987     .089

  4. A variable is a location in memory, referenced by an identifier, in which a
    data value is stored that can change in the program.
    A constant is a location in memory containing a data value that will not change.

  5. cout is used to send program output to an output device--such as the monitor
    or the printer.

If you are ready for the quiz
click here!!
For help or lab sign-up, contact Mrs. B. Driskell

These pages were developed through GirlTECH , a teacher training and student technology council program sponsored by the Center for Research on Parallel Computation (CRPC), a National Science Foundation Science and Technology Center. Copyright July,1998 by Beverly Driskell [bdriskel@cs.rice.edu].