Basic C++ Flashcards

(111 cards)

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
Nested if statements
if the logic needed requires more than two alternatives, __________ can be used.
62
repetition structure
statement that allows an action to be repeated (iteration, looping)
63
C++ repetition statements (examples)
while
66
while statement syntax
while (logical expression)
68
while statement semantics
step 1: evaluate expression
74
infinite loop definition
if the expression remains true, the loop will not be exited
75
++ increment operator (e.g., num++;)
unary operator used to add 1 to a variable
76
-- decrement operator (e.g., num--;)
unary operator used to subtract 1 from a variable
77
batch processing
all input gathered together and placed in a file, program designed to get data from file as needed (no prompting required)
78
Linux input redirection operator: <
changes the default input source to a specified file
79
Linux input redirection operator: >
changes the default output destination to a specified file
80
Linux redirection sample code
[bobby ~]$ ./a.out < myinput > myoutput
81
The key to designing a program to run in batch mode.
Design the program as if were interactive but leave out the prompts.
82
Count-controlled looping
Loop designed to run a specific
85
Sentinel-controlled loop
Loop designed to repeat an action until a special value is encountered.
86
Sentinel-controlled syntax
while (data != sentinel)
87
End-of-file controlled loop
Loop designed to continue processing data until all data in the file has been read.
88
End-of-file controlled loop syntax
!cin.eof()
89
Flag-controlled loop
Loop where bool variable is used to control
91
Flag-controlled loop syntax
bool finished = false; //finished is the flag
93
for statement
a statement specifically designed for implementing count-controlled loops.
94
for statement syntax
for (initial statement; loop condition; update statement)
96
for statement semantics
step 1: execute initial statement
104
Nested looping
When the solution to a task requires repetition, and the task must be repeated, ________ can be used.
105
The two types of functions in C++
- value-returning function, and
107
value-returning function (definition)
Function designed to compute and return EXACTLY ONE value using a return statement.
108
void function
Function that is series of statements designed to perform a task. This type of function does not have a specific data type.
109
What is needed to implement a function
consists of a heading and a body, placed after the main function
110
function prototype
placed after using statement and const declarations, before heading for main function - provides information to compiler about the function
111
function call
placed inside any function, used when you want the statements in the function to be executed.
112
function syntax
// preprocessor directives
123
value-returning function definition syntax
data_type function_name (formal parameter list) // heading
129
formal parameter (definition)
variable declared in a function heading
130
formal parameter (syntax)
(data_type identifier, data_type identifier, ...)
131
parameters passed by value
a copy of the actual parameter's value is sent to the function. The function uses the copy in all
134
local variable
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
actual parameter
a variable or expression listed in a call to a function.
136
void function
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
void function syntax
void function_name (formal parameter list) //heading
141
parameters passed by reference
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
True or False: A void function call is a stand-alone statement.
True
143
Scope of an identifier
the region (part) of a program where an identifier is recognized (visible) and accessible.
144
Local identifier
identifier declared within a function (or block)
145
Global identifier
identifier declared outside of every function definition
146
automatic variable
the memory for a local variable is (by default) allocated at declaration and deallocated at block exit
147
static variable
the memory for a global variable is allocated at declaration and de-allocated when program is finished executing
148
syntax for making local variables static
static datatype variablename = startvalue;
150
pwd
lists the current working path directory
151
make
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
when a parameter is passed by reference, the actual parameter MUST be a _______
variable
153
computer
an electronic device capable of performing commands (input, output, storage, arithmetic and logic operations)
154
hardware
the physical components of a computer and its surrounding (peripheral) devices
155
software
sets of instructions to be executed by the computer, i.e., programs
156
system software
programs designed to control the computer
157
operating system
a set of programs that control overall computer activity and provide services
158
Windows and Linux
The two operating systems that the CS computer lab machines boot to.
159
CPU and main memory, secondary storage, input and output devices
basic components of computer hardware
160
application software
programs designed to perform specific tasks
161
system software and application software
the two main types of software
162
editor
program used to create and modify text based files
163
emacs
editor used in CS labs
164
case sensitive
both linux and C++ are ___________, meaning that upper case and lower case letters are different
165
ASCII
collating code commonly used by computers for encoding data into sequences of bits
166
128 (numbered 0-127)
the number of characters in ASCII
167
machine language, assembly language, and high-level language
types of programming languages
168
machine language
instructions made up of sequences of 0s and 1s
169
assembly language
instructions made up of mnemonic codes
170
high-level language
instructions are closer to natural language, use familiar words and symbols
171
machine language
programming language that:
174
assembly language
programming language that:
177
high-level language
programming language that:
180
BASIC, FORTRAN, Pascal, Java, C, C++
Examples of high-level languages
181
compiler
a program that translates instructions written in a high-level language into the equivalent machine code
182
g++
the compiler used in the CS labs for C++
188
}
the parts required in every C++ program
189
Program Development
a problem solving process
190
Analysis, Implementation, Maintenance
Three steps of Program Development
191
algorithm
a step-by-step procedure for solving a problem in a finite amount of time
192
source file
a human readable file that contains C++ program
193
object file
executable version of program
194
program
a sequence of statements whose objective is to accomplish a task
195
programming
process of planning and creating a program
196
programming language
a set of rules, symbols, and special words
197
syntax
grammar rules of the language; compiler will try to identify and locate syntax errors
198
semantics
meaning of the instructions in the language; compiler cannot find these errors - often called logic errors
199
comments
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
preprocessor directives
tells the computer where to find the library for operations and data types