Basic C++ Flashcards

1
Q

selection structure (definition)

A

statement that allows the program to choose between alternative actions (make a decision)

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

selection structure (examples)

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

if statement building blocks are…

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

action

A

a C++ statement

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

C++ statements that can be actions

A
  • output (cout)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

bool data type

A
  • used to store a logical value
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

bool example code

A

bool valid, finished;

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

logical (Boolean) expression (definition)

A

an expression that evaluates to true or false

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

relational operators

A

operators that are used to compare values

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

logical (Boolean) expression (facts)

A
  • in C++, any non-zero value is considered true, 0 is considered false
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
28
Q

relational operators (definition)

A

operators that are used to compare values

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

relational operators (examples)

A

< <= > >=

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

Equality operator (symbol)

A

==

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

Assignment operator (symbol)

A

=

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

Equality operator (==) vs. Assignment operator (=)

A

The equality operator (==) is used to compare values the assignment operator (=) is used to store values. It is important to use the == operator in logical expressions.

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

Compare like types (tip)

A

When creating logical expressions is to best to

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

logical operators (definition)

A

operators used to connect or change logical expressions

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

logical operators (examples)

A

! - not

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

Operator precedence

A

!

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

short circuit evaluation

A

process in which the computer evaluates a logical expression from left to right and stops as soon as the value of the expression is known.

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

basic if statement syntax

A

if (logical expression)

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

if statement semantics

A

evaluate logical expression

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

extended form of if statement syntax

A

if (logical expression)

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

extended form of if statement semantics

A

evaluate logical expression

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

Nested if statements

A

if the logic needed requires more than two alternatives, __________ can be used.

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

repetition structure

A

statement that allows an action to be repeated (iteration, looping)

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

C++ repetition statements (examples)

A

while

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

while statement syntax

A

while (logical expression)

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

while statement semantics

A

step 1: evaluate expression

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

infinite loop definition

A

if the expression remains true, the loop will not be exited

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

++ increment operator (e.g., num++;)

A

unary operator used to add 1 to a variable

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

– decrement operator (e.g., num–;)

A

unary operator used to subtract 1 from a variable

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

batch processing

A

all input gathered together and placed in a file, program designed to get data from file as needed (no prompting required)

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

Linux input redirection operator: <

A

changes the default input source to a specified file

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

Linux input redirection operator: >

A

changes the default output destination to a specified file

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

Linux redirection sample code

A

[bobby ~]$ ./a.out < myinput > myoutput

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

The key to designing a program to run in batch mode.

A

Design the program as if were interactive but leave out the prompts.

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

Count-controlled looping

A

Loop designed to run a specific

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

Sentinel-controlled loop

A

Loop designed to repeat an action until a special value is encountered.

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

Sentinel-controlled syntax

A

while (data != sentinel)

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

End-of-file controlled loop

A

Loop designed to continue processing data until all data in the file has been read.

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

End-of-file controlled loop syntax

A

!cin.eof()

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

Flag-controlled loop

A

Loop where bool variable is used to control

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

Flag-controlled loop syntax

A

bool finished = false; //finished is the flag

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

for statement

A

a statement specifically designed for implementing count-controlled loops.

94
Q

for statement syntax

A

for (initial statement; loop condition; update statement)

96
Q

for statement semantics

A

step 1: execute initial statement

104
Q

Nested looping

A

When the solution to a task requires repetition, and the task must be repeated, ________ can be used.

105
Q

The two types of functions in C++

A
  • value-returning function, and
107
Q

value-returning function (definition)

A

Function designed to compute and return EXACTLY ONE value using a return statement.

108
Q

void function

A

Function that is series of statements designed to perform a task. This type of function does not have a specific data type.

109
Q

What is needed to implement a function

A

consists of a heading and a body, placed after the main function

110
Q

function prototype

A

placed after using statement and const declarations, before heading for main function - provides information to compiler about the function

111
Q

function call

A

placed inside any function, used when you want the statements in the function to be executed.

112
Q

function syntax

A

// preprocessor directives

123
Q

value-returning function definition syntax

A

data_type function_name (formal parameter list) // heading

129
Q

formal parameter (definition)

A

variable declared in a function heading

130
Q

formal parameter (syntax)

A

(data_type identifier, data_type identifier, …)

131
Q

parameters passed by value

A

a copy of the actual parameter’s value is sent to the function. The function uses the copy in all

134
Q

local variable

A

A variable declared inside a program block is said to be local to the block. It exists and is recognized only inside the program block.

135
Q

actual parameter

A

a variable or expression listed in a call to a function.

136
Q

void function

A

a series of statements designed to perform a task. This type of function does not have a specific data type and does not directly return a value.

137
Q

void function syntax

A

void function_name (formal parameter list) //heading

141
Q

parameters passed by reference

A

the address (memory location) of the actual parameter is sent to the function. The function accesses the actual parameter in all statements that reference the parameter. Any changes made to the parameter are made to the actual parameter. The original parameter (in the calling function) is changed.

142
Q

True or False: A void function call is a stand-alone statement.

A

True

143
Q

Scope of an identifier

A

the region (part) of a program where an identifier is recognized (visible) and accessible.

144
Q

Local identifier

A

identifier declared within a function (or block)

145
Q

Global identifier

A

identifier declared outside of every function definition

146
Q

automatic variable

A

the memory for a local variable is (by default) allocated at declaration and deallocated at block exit

147
Q

static variable

A

the memory for a global variable is allocated at declaration and de-allocated when program is finished executing

148
Q

syntax for making local variables static

A

static datatype variablename = startvalue;

150
Q

pwd

A

lists the current working path directory

151
Q

make

A

alternative method for compiling your C++ programs where each of your executable files will have different names so that if you want to run several different programs in the same directory, you do not have to recompile each time you want to run a different program.

152
Q

when a parameter is passed by reference, the actual parameter MUST be a _______

A

variable

153
Q

computer

A

an electronic device capable of performing commands (input, output, storage, arithmetic and logic operations)

154
Q

hardware

A

the physical components of a computer and its surrounding (peripheral) devices

155
Q

software

A

sets of instructions to be executed by the computer, i.e., programs

156
Q

system software

A

programs designed to control the computer

157
Q

operating system

A

a set of programs that control overall computer activity and provide services

158
Q

Windows and Linux

A

The two operating systems that the CS computer lab machines boot to.

159
Q

CPU and main memory, secondary storage, input and output devices

A

basic components of computer hardware

160
Q

application software

A

programs designed to perform specific tasks

161
Q

system software and application software

A

the two main types of software

162
Q

editor

A

program used to create and modify text based files

163
Q

emacs

A

editor used in CS labs

164
Q

case sensitive

A

both linux and C++ are ___________, meaning that upper case and lower case letters are different

165
Q

ASCII

A

collating code commonly used by computers for encoding data into sequences of bits

166
Q

128 (numbered 0-127)

A

the number of characters in ASCII

167
Q

machine language, assembly language, and high-level language

A

types of programming languages

168
Q

machine language

A

instructions made up of sequences of 0s and 1s

169
Q

assembly language

A

instructions made up of mnemonic codes

170
Q

high-level language

A

instructions are closer to natural language, use familiar words and symbols

171
Q

machine language

A

programming language that:

174
Q

assembly language

A

programming language that:

177
Q

high-level language

A

programming language that:

180
Q

BASIC, FORTRAN, Pascal, Java, C, C++

A

Examples of high-level languages

181
Q

compiler

A

a program that translates instructions written in a high-level language into the equivalent machine code

182
Q

g++

A

the compiler used in the CS labs for C++

188
Q

}

A

the parts required in every C++ program

189
Q

Program Development

A

a problem solving process

190
Q

Analysis, Implementation, Maintenance

A

Three steps of Program Development

191
Q

algorithm

A

a step-by-step procedure for solving a problem in a finite amount of time

192
Q

source file

A

a human readable file that contains C++ program

193
Q

object file

A

executable version of program

194
Q

program

A

a sequence of statements whose objective is to accomplish a task

195
Q

programming

A

process of planning and creating a program

196
Q

programming language

A

a set of rules, symbols, and special words

197
Q

syntax

A

grammar rules of the language; compiler will try to identify and locate syntax errors

198
Q

semantics

A

meaning of the instructions in the language; compiler cannot find these errors - often called logic errors

199
Q

comments

A

nonexecutable statements that are included in a program to provide information about what the program does, how it works, what input is expected, what output is generated, who wrote it, etc.

200
Q

preprocessor directives

A

tells the computer where to find the library for operations and data types