Chapter 3 Conditions Flashcards

1
Q

What is a good general practice to add to ending braces?

A

Add a comment to denote what the end brace is used for

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

What are three common operators found in Boolean algebra and what values do they manipulate?

A

“And”, “or”, and “not” are used to manipulate the values “true” and “false”.

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

What are three common operators found in Boolean algebra?

A

And
Or
Not

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

Who is Boolean algebra named after?

A

George Boole, a nineteenth-century English mathematician.

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

When using the “and” operator, what is required for the compound condition (entire expression) to be true?

A

Both sides of the “and” operator must be true

Ex.: 3==3 and 4==4 is true

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

When using the “or” operator, what is required for the compound condition (entire expression) to be true?

A

At least one side of the “or” operator must be true

Ex.: 3==3 or 3==4 is true

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

How does the C programming language treat all nonzero and zero values?

A

All nonzero values are treated as true while all zero values are treated as false.

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

What character set represents the “and” Boolean operator?

A

&& (two ampersands)

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

What library is the “isdigit ()” function a part of?

A

The library.

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

What library is the “isdigit ()” function a part of?

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

What is the “switch (x)” structure used for?

A

When programmers want to evaluate a user’s response to a specific set of choices.

Ex.: When a user selects an item from a menu.

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

What are three common operators found in Boolean algebra?

A

And
Or
Not

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

Who is Boolean algebra named after?

A

George Boole, a nineteenth-century English mathematician.

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

When using the “and” operator, what is required for the compound condition (entire expression) to be true?

A

Both sides of the “and” operator must be true

Ex.: 3==3 and 4==4 is true

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

What is the “srand ()” function used for?

A

The “srand ()” function seeds a variable into the rand () function to dictate the random number generator algorithm.

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

What is commonly paired with the srand () function to produce a psuedorandom number generator so that numbers are as random as possible?

A

The “time (NULL)” function.

Ex.: srand (time (NULL))

17
Q

What character set represents the “and” Boolean operator?

A

&& (two ampersands)

18
Q

What character set represents the “or” Boolean operator?

A

|| (two pipe characters)

19
Q

What library is the “isdigit ()” function a part of?

A

The ctype.h library.

20
Q

What is the “isdigit ()” function used for?

A

A tool used to validate whether the user entered either digits or non-digit characters.

The “isdigit ()” function returns “true” if its passed-in value evaluates to a digit, and “false (0)” if not.

21
Q

What is the “switch (x)” structure used for?

A

When programmers want to evaluate a user’s response to a specific set of choices.

Ex.: When a user selects an item from a menu.

22
Q

What keyword is used to stop the processing of each “case” statement after the appropriate “case” statement is matched?

23
Q

What function is used to generate a random number and what operator is it commonly paired with?

A

The “rand ()” function. It is paired with the modulus (%) operator:

(rand () % 10) + 1 This will generate a random number between 0 and 9 and then add 1 so the new range will be 1 and 10.

24
Q

What is a disadvantage of the “rand ()” function?

A

The “rand ()” function generates the same sequence of random numbers repeatedly. It cannot generate another random number without the use of the “srand ()” function.

25
What is the "srand ()" function used for?
The "srand ()" function tells the "rand()" function to produce a different random number every time it is executed.
26
What is commonly paired with the srand () function to produce a psuedorandom number generator so that numbers are as random as possible?
The "time (NULL)" function. Ex.: srand (time (NULL))
27
Conditions are implemented using what type of structure?
"if" structures which contains an expression enclosed within parenthesis