BASIC ELEMENTS OF C++ Flashcards
A sequence of statements whose objective is to accomplish a task
Computer Program
The process of planning and creating a program
Programming
collection of statements
Subprogram or Function
rules that specify which statements (instructions) are legal or valid
Syntax rules
determine the meaning of the instructions
Semantic rules
a set of rules, symbols, and special words
Programming language
Two types of Comment Line
Single line and Multiple line
A single line begins with what symbol
//
Multiple line is enclosed with a symbol
/* and */
the smallest individual unit of a program written in any language
token
C++ tokens include
special symbols, word symbols, and identifiers
Special symbols in C++ include:
+ - * /
. ; ? ,
<= != == >=
Cannot be redefined within a program
Reserved word symbols or keywords
Cannot be used for anything other than their intended use
Reserved word symbols or keywords
Examples of Reserved Words
int
float
double
char
const
void
return
name of something that appears in a program
identifier
Consists of letters, digits, and the underscore character (_)
identifier
identifiers must begin with
a letter or underscore
TRUE OR FALSE
C++ is case sensitive
TRUE
TRUE OR FALSE
NUMBER is the same as number
FALSE
Two predefined identifiers
cout and cin
TRUE OR FALSE
Unlike reserved words, predefined identifiers may be redefined, but it is not a good idea
TRUE
3 Legal identifiers in C++
first
conversion
payRate
Include blanks, tabs, and newline characters
Whitespaces
it separates special symbols, reserved words, and identifiers
whitespaces
set of values together with a set of allowed operations
data Type
C++ data types fall into three categories:
Simple data type
Structured data type
Pointers
numbers without a decimal
integers
Simple Data Types
Integral
Floating-point
Enumeration
Integral can further be categorized:
char, short, int, long, bool, unsigned char, unsigned short, unsigned int, unsigned long
simple data with decimal numbers
Floating-point
a user-defined data type
Enumeration
to manipulate logical expressions
bool Data Type
smallest integral data type
Data type char
It is used for single characters: letters, digits, and special symbols
char Data Type
C++ uses scientific notation to represent real numbers
Floating-Point Data Types
ordering of characters based on the character set code
Collating sequence
are only used for separating items in a list
Commas
represents any real number
float and double
Maximum number of significant digits (decimal places) for float values
6 or 7
Maximum number of significant digits for double
15
maximum number of significant digits
Precision
float values are called
single precision
double values are called
double precision
TRUE OR FALSE
A comma cannot be used within an integer
TRUE
Two values of bool type or 2 Logical values
true or false
TRUE OR FALSE
In Data Type char, each character is enclosed in single quotes
TRUE
example:
‘A’, ‘a’, ‘0’, ‘*’, ‘+’, ‘$’, ‘&’
TRUE OR FALSE
A blank space is not a character
FALSE
IT IS A CHARACTER
Written ‘ ‘, with a space left between the single quotes
ASCII
American Standard Code for Information Interchange
TRUE OR FALSE
Characters have a predefined ordering based on the ASCII numeric value
TRUE
Syntax rule to declare a variable is:
dataType identifier;
C++ arithmetic operators include:
+ addition
- subtraction (or negation)
* multiplication
/ division
% mod (modulus or remainder)
TRUE OR FALSE
Modulus (%) can only be used with integral data types
TRUE
TRUE OR FALSE
When you use / with integral data types, the integral result is rounded off
FALSE
the result is truncated (no rounding)
contain values and arithmetic operators
Arithmetic expressions
the numbers appearing in the expressions
Operands
can be unary (one operand) or binary (two operands)
Operators