Comp Sci Ch 3 Ch 4 Flashcards

1
Q

What is a branch and when is it executed?

A

and if statement executed under a certain condition

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

What is an if-else branch and when is it executed?

A

2 branches
if branch executed if true, then else is executed if false

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

What is an if-else-if-else branch?

A

each branch is checked until one is found to be true

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

In a conditional expression you use…

A

==, and relational operators

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

What is a bool value?

A

True or False

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

How are characters compared?

A

with their ASCII

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

How are strings compared?

A

same number of characters and if their characters are identical

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

What are the logical operators

A

&&, ||, !

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

How to compare floating point numbers?

A

fabs (x-y) < .0001

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

What is epsilon?

A

the difference threshold that floating point numbers are equal

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

How do you get a random number?

A

rand()

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

What needs to be enabled to use rand()

A

(#) include < cstdlib >

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

How do you get a specific range of random numbers?

A

rand() % (largest-smallest +1) + smallest

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

How do you determine number values in range of randomization coputation

A

large-small +1

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

What is pseudo?

A

not actually but having the appearance of

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

How is the sequence determined?

A

seed

17
Q

How do you get a different/make a different seed?

A

srand(#), CALLED ONCE ONLY

18
Q

How do you get a truly random sequence each time?

A

srand(time(0));

19
Q

What needs to be enabled to use time (0)?

A

(#) include < ctime>

20
Q

What is a do-while loop?

A

running the body at least once then checking if run again
- do then check
do {
}while (expression);

21
Q

What is a loop?

A

repeatedly executes body while expression is true

22
Q

What is an iteration?

A

each time a loop’s statements execute

23
Q

What is a while loop?

A

checks to run
check, and run if expression is true
while (expression) {
}

24
Q

What is a sentinel loop?

A

loop that keeps going until a value stops it

25
Q

What is a sentinel value?

A

a special value indicating the end of a list

26
Q

When trying to find a range, do you always need the plus one?

A

add the plus one when the large number is included

27
Q

What is the order of evaluation?

A

P ! M R E L
parentheses
not
math
relational
equality
logical