BASIC ELEMENTS OF C++ Flashcards

1
Q

A sequence of statements whose objective is to accomplish a task

A

Computer Program

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

The process of planning and creating a program

A

Programming

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

collection of statements

A

Subprogram or Function

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

rules that specify which statements (instructions) are legal or valid

A

Syntax rules

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

determine the meaning of the instructions

A

Semantic rules

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

a set of rules, symbols, and special words

A

Programming language

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Two types of Comment Line

A

Single line and Multiple line

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

A single line begins with what symbol

A

//

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Multiple line is enclosed with a symbol

A

/* and */

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

the smallest individual unit of a program written in any language

A

token

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

C++ tokens include

A

special symbols, word symbols, and identifiers

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Special symbols in C++ include:

A

+ - * /
. ; ? ,
<= != == >=

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Cannot be redefined within a program

A

Reserved word symbols or keywords

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Cannot be used for anything other than their intended use

A

Reserved word symbols or keywords

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Examples of Reserved Words

A

int
float
double
char
const
void
return

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

name of something that appears in a program

A

identifier

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Consists of letters, digits, and the underscore character (_)

A

identifier

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

identifiers must begin with

A

a letter or underscore

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

TRUE OR FALSE

C++ is case sensitive

A

TRUE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

TRUE OR FALSE

NUMBER is the same as number

A

FALSE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

Two predefined identifiers

A

cout and cin

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

TRUE OR FALSE

Unlike reserved words, predefined identifiers may be redefined, but it is not a good idea

A

TRUE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

3 Legal identifiers in C++

A

first
conversion
payRate

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

Include blanks, tabs, and newline characters

A

Whitespaces

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
it separates special symbols, reserved words, and identifiers
whitespaces
26
set of values together with a set of allowed operations
data Type
27
C++ data types fall into three categories:
Simple data type Structured data type Pointers
28
numbers without a decimal
integers
29
Simple Data Types
Integral Floating-point Enumeration
30
Integral can further be categorized:
char, short, int, long, bool, unsigned char, unsigned short, unsigned int, unsigned long
31
simple data with decimal numbers
Floating-point
32
a user-defined data type
Enumeration
33
to manipulate logical expressions
bool Data Type
34
smallest integral data type
Data type char
35
It is used for single characters: letters, digits, and special symbols
char Data Type
36
C++ uses scientific notation to represent real numbers
Floating-Point Data Types
37
ordering of characters based on the character set code
Collating sequence
38
are only used for separating items in a list
Commas
39
represents any real number
float and double
40
Maximum number of significant digits (decimal places) for float values
6 or 7
41
Maximum number of significant digits for double
15
42
maximum number of significant digits
Precision
43
float values are called
single precision
44
double values are called
double precision
45
TRUE OR FALSE A comma cannot be used within an integer
TRUE
46
Two values of bool type or 2 Logical values
true or false
47
TRUE OR FALSE In Data Type char, each character is enclosed in single quotes
TRUE example: 'A', 'a', '0', '*', '+', '$', '&'
48
TRUE OR FALSE A blank space is not a character
FALSE IT IS A CHARACTER Written ' ', with a space left between the single quotes
49
ASCII
American Standard Code for Information Interchange
50
TRUE OR FALSE Characters have a predefined ordering based on the ASCII numeric value
TRUE
51
Syntax rule to declare a variable is:
dataType identifier;
52
C++ arithmetic operators include:
+ addition - subtraction (or negation) * multiplication / division % mod (modulus or remainder)
53
TRUE OR FALSE Modulus (%) can only be used with integral data types
TRUE
54
TRUE OR FALSE When you use / with integral data types, the integral result is rounded off
FALSE the result is truncated (no rounding)
55
contain values and arithmetic operators
Arithmetic expressions
56
the numbers appearing in the expressions
Operands
57
can be unary (one operand) or binary (two operands)
Operators
58
have the same level of precedence and are evaluated last
*, /, and % + and -
59
TRUE OR FALSE When operators are on the same level Operations are performed from left to right (associativity)
TRUE
60
all operands are integers
Integral expression
61
all operands are floating-point
Floating-point expression
62
2 types of expression
Integral expression and Floating-point expression
63
Has operands of different data types
Mixed expression
64
If operator has same types of operands - The operator is evaluated according to the type of the operands - If operator has both types of operands
...
65
Integer is changed to floating-point - Operator is evaluated - Result is floating-point
...
66
Type Conversion (Casting)
Implicit type coercion Cast operator (also called type conversion or type casting)
67
when the value of one type is automatically changed to another type
Implicit type coercion
68
provides explicit type conversion
Cast operator (also called type conversion or type casting)
69
a programmer-defined type supplied in ANSI/ISO Standard C++ library
Data type string
70
a sequence of zero or more characters enclosed in double quotation marks
string
71
a string with no characters
null (or empty) string
72
memory location whose content cannot change during execution
Named constant
73
Syntax to declare a named constant
const dataType identifier = value;
74
TRUE OR FALSE In C++, const is not a reserved word
FALSE bcs const is a reserved word
75
memory location whose content may change during execution
Variable
76
Syntax to declare one or multiple variables
dataType identifier, identifier, ... ;
77
Ways to place data into a variable
Use C++’s assignment statement Use input (read) statements
78
The assignment statement takes the form:
variable = expression;
79
In C++, = is called the
assignment operator
80
The assignment operator is evaluated from
right to left
81
is used with >> to gather one or more inputs
cin
82
The stream extraction operator
>>
83
increase variable by 1
Increment operator (++)
84
Pre-increment:
++variable
85
Post-increment:
variable++
86
decrease variable by 1
Decrement operator: (--)
87
Pre-decrement:
--variable
88
Post-decrement:
variable--
89
The syntax of cout and << is:
cout << expression or manipulator << expression or manipulator ... ;
90
used to format the output
manipulator
91
The new line character (new line escape sequence)
'\n'
92
cursor moves to the beginning of the next line
Newline \n
93
cursor moves to the next tab stop
Tab \t
94
cursor moves one space to the left
Backspace \b
95
cursor moves to the beginning of the current line (not the next line)
Return \r
96
Backslash
\\
97
Singe quotation
\'
98
double quotation
\"
99
All preprocessor commands begin with
#
100
Every library has a name and is referred to by
a header file
101
are processed by the preprocessor program
Preprocessor directives
102
Syntax to include a header file
#include
103
a collection of functions, one of which is the function main
C++ program
104
The syntax of the function main used in this book has this form:
int main () { statement_1 . . . statement_n return 0; }
105
The first line of the function main is called
the heading of the function: int main ()
106
The statements enclosed between the curly braces ({ and }) form the
body of the function
107
Declaration statements declare things, such as
variables
108
statements that perform calculations, manipulate data, create output, accept input, etc.
Executable statements
109
will identify the syntax errors
compiler
110
indicate what is legal and what is not legal
syntax rules
111
are also used to separate reserved words and identifiers from each other and from other symbols
Blanks
112
TRUE OR FALSE Blanks must NEVER appear within a reserved word or identifier
TRUE
113
All C++ statements end with a semicolon also called a
statement terminator
114
{ and } are not C++ statements but can be regarded as
delimiters
115
set of rules that gives meaning to a language
semantics
116
can be self-documenting
indentifiers
117
executable statements that inform the user what to do
Prompt lines
118
Two forms of assignment
Simple and compound
119
Compound operators
+=, -=, *=, /=, %=
120
is a collection of functions, one of which is always called main
C++ program
121
consist of letters, digits, and underscores, and begin with a letter or an underscore
Identifiers
122
The arithmetic operators in C++ are
addition (+), subtraction (-), multiplication (*), division (/), and modulus (%)
123
are evaluated using the precedence associativity rules
Arithmetic expressions
124
All operands in an integral expression are
integers
125
All operands in a floating-point expression are
decimal numbers
126
expression contains both integers and decimal numbers
mixed expression
127
Use the ________ to explicitly convert values from one data type to another
cast operator
128
TRUE OR FALSE A named constant is initialized when declared
TRUE
129
TRUE OR FALSE All variables must be declared before used
TRUE
130
Use ___ and the ______________ >> to input from the standard input device
cin and the stream extraction operator >>
131
Use ___ and the ______________ << to output from the standard output device
cout and the stream insertion operator <<
132
are processed before the program goes through the compiler
Preprocessor commands
133
A file containing a C++ program usually ends with
the extension .cpp
134
TRUE OR FALSE A semicolon is placed at the end of these commands
FALSE No semicolon is placed at the end of these commands
135
comprised of preprocessor directives and program statements
Source code
136
results when object code is linked with the system resources
Executable code
137
Blanks must never appear within a
reserved word or identifier
138
All C++ statements end with
a semicolon
139
TRUE OR FALSE { and } are not C++ statements
TRUE
140
Avoid run-together words Solutions may include:
Capitalizing the beginning of each new word: annualSale Inserting an underscore just before a new word: annual_sale
141
Comments should appear in a program to:
Explain the purpose of the program Identify who wrote it Explain the purpose of particular statements
142
causes the insertion point to move to beginning of next line
endl
143
The stream insertion operator is
<<
144
The stream extraction operator is
>>