Module 6 Flashcards

(45 cards)

1
Q

___________ and ___________ operators are special operators which are unique to C and C++

A

Increment and decrement

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

The effect of these is to increase or decrease the value of the variable by 1.

A

Increment and decrement

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

The ________________ is denoted by ++ (now you
can guess why the updated version of C was called C++

A

increment operator

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

The ________________ is denoted by –

A

decrement operator

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

i++; ( the ________ form )

A

postfix

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

++i; ( the ________ form )

A

prefix

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

both of i++ and ++i which are equivalent to
__________ or they can be part of an expression.

A

i = i + 1;

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

The __________ version will use the old (not incremented) value in the expression, then once the expression has
ended (shown by a semicolon) only then is the value incremented.

A

postfix

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

The ___________ form increments the value straight
away, so the new value is used.

A

prefix

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

So if you set i = 10; and then print out its value, the expression
cout &laquo_space;_________ «endl;
will print out the value of 10. Once this expression is finished (once the endl; has been executed) then i is
incremented to give the new value of 11.

A

i++

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

On the other hand, if you used cout &laquo_space;________ «endl; then the first thing that happens is that i gets incremented, so
the value printed out is 11.

A

++i

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

// increment straight away

A

++i

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

// increment, but use old value if i++ is part of
an existing expression

A

i++

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

// decrement straight away

A

–i

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

// decrement, but use old value if i– is part of
an existing expression

A

i–

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

_________ have as objective to repeat a statement a certain number of times or while a condition is fulfilled.

A

Loops

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

its function is simply to repeat statement while expression is true.

A

while loop

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

The while loop format is:

A

while (expression) statement

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

When the program starts the user is prompted to insert a starting number for the countdown. Then the _______ loop begins, if the value entered by the user fulfills the condition, the block of instructions that follows will execute an indefinite number of times while the condition remains true.

20
Q

The do-while loop format is:

A

do statement while (condition);

21
Q

The __________ loop performs the statements first and then tests the condition. This means that the body of the loop is always executed at least once.

22
Q

The _________ loop performs the conditional test first and then executes the loop, so the statements within a loop may never be executed.

23
Q

The general form of a do…while loop is

A

do
{
statements;
}while(test_condition);

24
Q

There is a ___________ at the end of the while condition statement.
This terminates the whole statement and results in one more _______ than the equivalent while loop.

25
The for loop format is:
for (initialization; condition; increment) statement;
26
Many loops have these characteristics in common: 1. __________, 2. _____________________________________________, 3. ______________.
1. initialization, 2. a condition which evaluates either to FALSE or TRUE 3. an increment.
27
The for keyword marks the beginning of the code which will be repeated according to the conditions supplied in the parenthesis following the for. The general form of the statement is for ( ________ ; __________; ___________) { statements; } // end for
initialization; condition; increment
28
The _______________ statement is carried out only once when the loop is first entered.
initialization
29
The __________ is tested before each run through the body of the loop.
condition
30
The first test is immediately after ____________, so if the test fails the statements in the body are not run - just like a while loop.
initialization
31
The third expression, usually an increment or decrement to alter the _______________, is executed after the loop body and before the next test. This is the same as putting the increment or decrement at the end of a while loop.
test condition variable
32
________ provides places to specify an initialization instruction and an increase instruction. So this loop is specially designed to perform a repetitive action with a counter.
for loop
33
Using the _______________ we can specify more than one instruction in any of the fields included in a for loop, like in initialization, for example.
comma operator (,)
34
The _________________ is an instruction separator, it serves to separate more than one instruction where only one instruction is generally expected.
comma operator (,)
35
Using _________ we can leave a loop even if the condition for its end is not fulfilled.
break
36
It can be used to end an infinite loop, or to force it to end before its natural end. For example, we are going to stop the count down before it naturally finishes
break
37
The ___________ instruction causes the program to skip the rest of the loop in the present iteration as if the end of the statement block would have been reached, causing it to jump to the following iteration. For example, we are going to skip the number 5 in our countdown:
continue
38
It allows making an absolute jump to another point in the program.
goto instruction
39
You should use this feature carefully since its execution ignores any type of nesting limitation.
goto instruction
40
The destination point is identified by a label, which is then used as an argument for the _______ instruction. A label is made of a valid identifier followed by a colon (:).
goto
41
exit is a function defined in _________ library.
cstdlib (stdlib.h)
42
The purpose of _________ is to terminate the running program with an specific exit code.
exit function
43
exit function prototype
void exit (int exit code);
44
The _________ code is used by some operating systems and may be used by calling programs.
exit
45
By convention, an ______ code of 0 means that the program finished normally and any other value means an error happened.
exit