Operator

A symbol or function that can take values (arguments) and provide a value based on some computation in return

 

Identifier

A name associated with a function or data object (the name is created by the programmer, and the association is mental)

Should begin with a letter, can not begin with a digit.

May consist of any further combination of letters, digits, and the underscore.

Case is significant.

May NOT be a reserved word (word with meaning to C++)

 

Declaration

A statement that associates an identifier with a function or data object so a programmer can refer to it by name (the declaration makes the identifier have meaning)

Must be unique from others

All identifiers must be declared before they can be used

 

Data Type

Describes

Specific set of data values

Specific set of operations possible on those values

Can be

Built in: int, char, float

External: Created by programmer

 

Variable

A data location whose contained data can be changed

Associated with a data type

Referred to by an identifier

Compiler allocates (sets aside) memory for the type of data specified and associates the identifier with that place in memory

 

Constant

Data that can not be changed by the program

Two types

Literal

Actual value of the constant

Data type is implied by how the constant looks

‘A’

"Hello"

12

3.1415

Named (or symbolic)

A data location whose contained data can NOT be changed

Must be declared

Associated with a data type

Referred to by an identifier

Data type is explicit

Used for ease of changes

 

char data type

Built in

One (1) alphanumeric or punctuation symbol (space too)

Is enclosed in single quotes (apostrophes) to differentiate it from the rest of the symbols in the program

Possible operations

Comparison - subject to a specific ordering sequence as specified by the ASCII code

 

string data type

External

ONE OR MORE alphanumeric or punctuation symbols (spaces too)

Is enclosed in double quotes (SHIFT+apostrophe) to differentiate it

Must be contained on one line

Possible operations

Comparison – subject to same ordering as char data

Searching

Joining (concatenation)

Special strings

NULL String: Two double quotes together with nothing between.

 

Variable Declaration

Tells the compiler to associate a name and a data type with an identifier

Compiler allocates (sets aside) memory for the type of data specified and associates the identifier with that place in memory

Construction:

DataType Identifier [,Identifier…] ;

Three parts:

Data Type

List of Identifiers (one or more)

Termination (semicolon)

 

Constant Declaration

Tells the compiler to associate a name and a data type with an identifier

Compiler allocates (sets aside) memory for the type of data specified and associates the identifier with that place in memory

Construction:

const DataType Identifier = LiteralValue ;

Six parts:

Reserved word const

Data Type

One Identifier

Equal sign

Value to assign to this constant

Termination (semicolon)

 

Expression

An arrangement of identifiers, literals, and operators that can be evaluated to provide a value of a specific type

 

String Expressions

A particular expression using strings

+ is the concatenation operator for strings

The order of strings in the expression determines the order in which they appear at evaluation

Works only with named and literal string constants, string variables, and char data

At least one operand must be a string variable or named string constant.

 

Assignment Statement

A statement that stores the value of an expression into a variable

Construction:

Variable = Expression ;

Four parts:

One and only one variable identifier

Equal sign

Expression to provide the value for this variable

Termination (semicolon)

Replaces the previous value stored in the variable (if there was one) with the value of the expression

 

Output Statement

Sends output to standard output (screen)

Generated using the special stream variable cout and the insertion operator <<

Construction:

cout << Expression [<< Expression …] ;

Four parts:

Stream variable cout

Insertion operator

One or more expressions separated by the insertion operator

Termination (semicolon)

Left hand is a stream expression

Right hand is an expression

The special identifier endl denotes the end of line sequence and causes output to continue at the beginning of the next screen line.

 

Comments

Used to place documentation into code

Used to disable statements for debugging

Two types:

Block: /* */

Line: //

 

Formal Definitions

Block

A series of statements bounded by braces

FunctionDefinition

Heading and a Block

Program

Zero or more Declarations

One or more FunctionDefinitions

Statement

NullStatement ;

Declaration

AssignmentStatementl

OutputStatement

Block

Each statement except a compound statement is terminated by a semicolon.