Ch 2 - Gaddis Flashcards
Parts of a C++ program
C++ programs have parts and components that serve specific purposes.
cout Object
Use the cout object to display information on the computer’s screen.
The #include directive
The #include directive causes the contents of another file to be inserted into the program.
Variables & literals
Variables represent storage locations in the computer’s memory. Literals are constant values that are assigned to variables.
Identifiers
Choose variable names that indicate what the variables are used for.
Integer Data Types
There are many different types of data. Variables are classified according to their data type, which determines the kind of information that may be stored in them. Integer variables can only hold whole numbers.
C++ string class
Standard C++ provides a special data type for storing and working with strings.
Floating-point data types
Floating-point data types are used to define variables that can hold real numbers.
The bool data type
Boolean variables are set to either true or false.
sizeof
The sizeof operator may be used to determine the size of a data type on any system.
Variable assignments and initialization
An assignment operation assigns, or copies, a value into a variable. When a value is assigned to a variable as part of the variable’s definition, it is called an initialization.
Comments
Comments are notes of explanation that document lines or sections of a program. Comments are part of the program, but the compiler ignores them. They are intended for people who may be reading the source code.
Named constants
Literals may be given names that symbolically represent them in a program.
Programming style
Programming style refers to the way a programmer uses identifiers, spaces, tabs, blank lines, and punctuation characters to visually arrange a program’s source code. These are some, but not all, of the elements of programming style.