Deitel C++ Chapter 2

Home > Preview

The flashcards below were created by user mjs on FreezingBlue Flashcards.


  1. What is the purpose of comments and how are they denoted?
    // Comment lines begin with // because it tells the program to skip the line. They can also be written across several lines with /* and */

    Comments document programs and improve readability.
  2. What is a preprocessor directive? Give an example.
    They are processed by the preprocessor before the program is compiled. They begin with a #. They do not end with a semi-colon.

    #include <iostream>
  3. What does the line #include <iostream>
    do?
    It tells the preprocessor to include the input/output stream header in the program.

    It allows std::cin and std::cout and operators << and >> to be used in the program.
  4. What is the purpose of white-space?
    White space makes programmers easier to read. They are ignored by the compiler.
  5. What is main ?
    The program begins executing at main even if it does not appear first in the program.
  6. What does the keyword int do?
    Returns an integer value.

    • example:
    • int main ()
  7. Explain the purpose of braces. { }
    The left brace { begins the body of the function.

    The right brace } ends the body of the function.
  8. What are other names for a "string"?
    A character string, message string, or string literal.
  9. What is a statement terminator?
    Every statement must end with a semicolon.
  10. What is the output stream object?
    std::cout
  11. What is the input stream object?
    std::cin
  12. How are multiple data items concatated for output?
    With stream insertion operators.

    <<
  13. How are multiple data items concatated for input?
    With stream extraction operators.

    >>
  14. std::cout is normally connected to which hardware device?
    the screen for output
  15. std::cin is normally connected to which hardware device?
    the keyboard for input
  16. What is conversational computing (or interactive computing)?
    Interaction between the user and the computer.

    • examples:
    • std::cout std::cin
  17. How is an escape sequence formed and what does it do?
    An escape sequence is formed from a backslash \ and the next character.

    • i.e.
    • \ncreates a new line
  18. Define prompt.
    A message that directs the user to take a specific action.
  19. Define the keyword
    return
    (one of several means to) exit a function
  20. All variables in a C++ program must be _________ before they can be used.
    declared
  21. What are the rules for naming a variable in C++?
    • can contain letters, digits, and underscores (_)
    • cannot start with a digit
    • can be any length (some systems may impose limits on length)
    • cannot be one of the preset names (such as cout)
  22. Is C++ case sensitive?
    Yes, C++ is case sensitive.
  23. Where are calculations performed?
    Most calculations are performed in assignment statements.
  24. What is the name of a location in the computer's memory where a value can stored for use by a program?
    a variable
  25. What does the variable int hold?
    integer values, i.e. whole numbers

    • i.e.
    • -7, 11, 0, 23901
  26. Every variable stored in the computer's memory has:
    1)
    2)
    3)
    4)
    • 1) a name
    • 2) a value
    • 3) a type
    • 4) a size
  27. What does it mean when the process is nondestructive?
    A copy of the value is read, leaving the original value undisturbed.

    (keyword = read)
  28. What does it mean with the process is destructive?
    The new value replaced the previous value in that location. The previous value is lost.

    (think: write)
  29. What does the std::endl stream manipulator do?
    Outputs a newline, then flushes the output buffer.
  30. What are the order of operations for C++ arithmetic expressions?
    • ( ) (nested first)
    • * / % (from left to right)
    • + - (from left to right)
  31. When dividing integers in C++, does it return a decimal, fraction, or neither? Does it round the integer to the nearest whole number?
    None of the above. Any fractional part of the answer is truncated and no rounding occurs.

    • i.e.
    • mathematical answer: 346.875
    • C++ answer: 346
  32. What is the purpose of the modulus operator? What is the symbol used?
    The modulus operator, or %, yields the remainder after integer division. (It can only be used with integers.)

    • mathematical answer: 346.875
    • C++ % answer: 875
  33. What is an
    if

    statement? What is the format for using one?
    It allows a program to make a decision when a certain condition is met. If the condition is true, the statement in the body of the statement is executed. If it is not true, the statement is skipped.


    • if (condition)
    • statement;
  34. What is a relational operator? What is an equality operator? Which one has precedence?
    • Relational Operators: > and < and derivatives
    • Equality Operators: = and derivatives
    • Relational operators have precedence.
  35. What is the purpose of the declaration using



    std::cout;




    at the beginning of the program?
    The declaration eliminates the need to repeat the



    std::




    prefix. All that needs to be written thereafter is



    cout

Card Set Information

Author:
mjs
ID:
65573
Filename:
Deitel C++ Chapter 2
Updated:
2011-02-13 21:36:17
Tags:
Deitel Dietel
Folders:

Description:
Introduction to C++ Programming
Show Answers:

What would you like to do?

Home > Flashcards > Print Preview