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
Q

it separates special symbols, reserved words, and identifiers

A

whitespaces

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

set of values together with a set of allowed operations

A

data Type

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

C++ data types fall into three categories:

A

Simple data type
Structured data type
Pointers

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

numbers without a decimal

A

integers

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

Simple Data Types

A

Integral
Floating-point
Enumeration

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

Integral can further be categorized:

A

char, short, int, long, bool, unsigned char, unsigned short, unsigned int, unsigned long

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

simple data with decimal numbers

A

Floating-point

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

a user-defined data type

A

Enumeration

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

to manipulate logical expressions

A

bool Data Type

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

smallest integral data type

A

Data type char

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

It is used for single characters: letters, digits, and special symbols

A

char Data Type

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

C++ uses scientific notation to represent real numbers

A

Floating-Point Data Types

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

ordering of characters based on the character set code

A

Collating sequence

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

are only used for separating items in a list

A

Commas

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

represents any real number

A

float and double

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

Maximum number of significant digits (decimal places) for float values

A

6 or 7

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

Maximum number of significant digits for double

A

15

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

maximum number of significant digits

A

Precision

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

float values are called

A

single precision

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

double values are called

A

double precision

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

TRUE OR FALSE

A comma cannot be used within an integer

A

TRUE

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

Two values of bool type or 2 Logical values

A

true or false

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

TRUE OR FALSE

In Data Type char, each character is enclosed in single quotes

A

TRUE

example:
‘A’, ‘a’, ‘0’, ‘*’, ‘+’, ‘$’, ‘&’

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

TRUE OR FALSE

A blank space is not a character

A

FALSE

IT IS A CHARACTER
Written ‘ ‘, with a space left between the single quotes

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

ASCII

A

American Standard Code for Information Interchange

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

TRUE OR FALSE

Characters have a predefined ordering based on the ASCII numeric value

A

TRUE

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

Syntax rule to declare a variable is:

A

dataType identifier;

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

C++ arithmetic operators include:

A

+ addition
- subtraction (or negation)
* multiplication
/ division
% mod (modulus or remainder)

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

TRUE OR FALSE

Modulus (%) can only be used with integral data types

A

TRUE

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

TRUE OR FALSE

When you use / with integral data types, the integral result is rounded off

A

FALSE

the result is truncated (no rounding)

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

contain values and arithmetic operators

A

Arithmetic expressions

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

the numbers appearing in the expressions

A

Operands

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

can be unary (one operand) or binary (two operands)

A

Operators

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

have the same level of precedence and are evaluated last

A

*, /, and %

+ and -

59
Q

TRUE OR FALSE

When operators are on the same level
Operations are performed from left to right (associativity)

A

TRUE

60
Q

all operands are integers

A

Integral expression

61
Q

all operands are floating-point

A

Floating-point expression

62
Q

2 types of expression

A

Integral expression and Floating-point expression

63
Q

Has operands of different data types

A

Mixed expression

64
Q

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

A

65
Q

Integer is changed to floating-point
- Operator is evaluated
- Result is floating-point

A

66
Q

Type Conversion (Casting)

A

Implicit type coercion
Cast operator (also called type conversion or type casting)

67
Q

when the value of one type is automatically changed to another type

A

Implicit type coercion

68
Q

provides explicit type conversion

A

Cast operator (also called type conversion or type casting)

69
Q

a programmer-defined type supplied in ANSI/ISO Standard C++ library

A

Data type string

70
Q

a sequence of zero or more characters enclosed in double quotation marks

A

string

71
Q

a string with no characters

A

null (or empty) string

72
Q

memory location whose content cannot change during execution

A

Named constant

73
Q

Syntax to declare a named constant

A

const dataType identifier = value;

74
Q

TRUE OR FALSE

In C++, const is not a reserved word

A

FALSE

bcs const is a reserved word

75
Q

memory location whose content may change during execution

A

Variable

76
Q

Syntax to declare one or multiple variables

A

dataType identifier, identifier, … ;

77
Q

Ways to place data into a variable

A

Use C++’s assignment statement
Use input (read) statements

78
Q

The assignment statement takes the form:

A

variable = expression;

79
Q

In C++, = is called the

A

assignment operator

80
Q

The assignment operator is evaluated from

A

right to left

81
Q

is used with&raquo_space; to gather one or more inputs

A

cin

82
Q

The stream extraction operator

A

> >

83
Q

increase variable by 1

A

Increment operator (++)

84
Q

Pre-increment:

A

++variable

85
Q

Post-increment:

A

variable++

86
Q

decrease variable by 1

A

Decrement operator: (–)

87
Q

Pre-decrement:

A

–variable

88
Q

Post-decrement:

A

variable–

89
Q

The syntax of cout and &laquo_space;is:

A

cout &laquo_space;expression or manipulator &laquo_space;expression or manipulator … ;

90
Q

used to format the output

A

manipulator

91
Q

The new line character (new line escape sequence)

A

‘\n’

92
Q

cursor moves to the beginning of the next line

A

Newline \n

93
Q

cursor moves to the next tab stop

A

Tab \t

94
Q

cursor moves one space to the left

A

Backspace \b

95
Q

cursor moves to the beginning of the current line (not the next line)

A

Return \r

96
Q

Backslash

A

\

97
Q

Singe quotation

A

'

98
Q

double quotation

A

"

99
Q

All preprocessor commands begin with

A

#

100
Q

Every library has a name and is referred to by

A

a header file

101
Q

are processed by the preprocessor program

A

Preprocessor directives

102
Q

Syntax to include a header file

A

include <headerFileName></headerFileName>

103
Q

a collection of functions, one of which is the function main

A

C++ program

104
Q

The syntax of the function main used in this book has this form:

A

int main ()
{
statement_1
.
.
.
statement_n
return 0;
}

105
Q

The first line of the function main is called

A

the heading of the function: int main ()

106
Q

The statements enclosed between the curly braces ({ and }) form the

A

body of the function

107
Q

Declaration statements declare things, such as

A

variables

108
Q

statements that perform calculations, manipulate data, create output, accept input, etc.

A

Executable statements

109
Q

will identify the syntax errors

A

compiler

110
Q

indicate what is legal and what is not legal

A

syntax rules

111
Q

are also used to separate reserved words and identifiers from each other and from other symbols

A

Blanks

112
Q

TRUE OR FALSE

Blanks must NEVER appear within a reserved word or identifier

A

TRUE

113
Q

All C++ statements end with a semicolon also called a

A

statement terminator

114
Q

{ and } are not C++ statements but can be regarded as

A

delimiters

115
Q

set of rules that gives meaning to a language

A

semantics

116
Q

can be self-documenting

A

indentifiers

117
Q

executable statements that inform the user what to do

A

Prompt lines

118
Q

Two forms of assignment

A

Simple and compound

119
Q

Compound operators

A

+=, -=, *=, /=, %=

120
Q

is a collection of functions, one of which is always called main

A

C++ program

121
Q

consist of letters, digits, and underscores, and begin with a letter or an underscore

A

Identifiers

122
Q

The arithmetic operators in C++ are

A

addition (+), subtraction (-), multiplication (*), division (/), and modulus (%)

123
Q

are evaluated using the precedence associativity rules

A

Arithmetic expressions

124
Q

All operands in an integral expression are

A

integers

125
Q

All operands in a floating-point expression are

A

decimal numbers

126
Q

expression contains both integers and decimal numbers

A

mixed expression

127
Q

Use the ________ to explicitly convert values from one data type to another

A

cast operator

128
Q

TRUE OR FALSE

A named constant is initialized when declared

A

TRUE

129
Q

TRUE OR FALSE

All variables must be declared before used

A

TRUE

130
Q

Use ___ and the ______________&raquo_space; to input from the standard input device

A

cin and the stream extraction operator

> >

131
Q

Use ___ and the ______________ &laquo_space;to output from the standard output device

A

cout and the stream insertion operator

«

132
Q

are processed before the program goes through the compiler

A

Preprocessor commands

133
Q

A file containing a C++ program usually ends with

A

the extension .cpp

134
Q

TRUE OR FALSE

A semicolon is placed at the end of these commands

A

FALSE

No semicolon is placed at the end of these commands

135
Q

comprised of preprocessor directives and program statements

A

Source code

136
Q

results when object code is linked with the system resources

A

Executable code

137
Q

Blanks must never appear within a

A

reserved word or identifier

138
Q

All C++ statements end with

A

a semicolon

139
Q

TRUE OR FALSE

{ and } are not C++ statements

A

TRUE

140
Q

Avoid run-together words
Solutions may include:

A

Capitalizing the beginning of each new word: annualSale
Inserting an underscore just before a new word: annual_sale

141
Q

Comments should appear in a program to:

A

Explain the purpose of the program
Identify who wrote it
Explain the purpose of particular statements

142
Q

causes the insertion point to move to beginning of next line

A

endl

143
Q

The stream insertion operator is

A

«

144
Q

The stream extraction operator is

A

> >