Chapter 3 Flashcards

1
Q

define boolean expression

A

an expression that evaluates to a boolean value: true or false.

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

define boolean expression

A

an expression that evaluates to a boolean value: true or false.

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

What is the operator for less than?

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

What is the operator for less than or equal to?

A

<=

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

What is the operator for greater than?

A

>

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

What is the operator for greater than or equal to?

A

> =

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

which is correct => or >= ?

A

> =

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

what is the operator for equal to?

A

==

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

what is the operator for not equal to?

A

!=

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

Which is correct != or =! ?

A

!=

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

what is the bool data type used for?

A

it is used for declaring boolean variables

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

____ and ___ are boolean literals

A

true and false

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

____ statements executes an action if and only if the condition is true

A

if

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

____ statements executes an action if and only if the condition is true

A

if

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

what is the syntax for an if-else statement?

A
if (boolean-expression)
{ 
statement(s)-for-the-true-case;
}
else
{ 
statement(s)-for-the-false-case;
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is the operator for less than or equal to?

A

<=

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

what function can you use to generate a random integerr?

A

rand( )

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

What is the operator for greater than or equal to?

A

> =

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

which is correct => or >= ?

A

> =

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

what is the operator for equal to?

A

==

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

what is the operator for not equal to?

A

!=

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

Which is correct != or =! ?

23
Q

what is the bool data type used for?

A

it is used for declaring boolean variables

24
Q

____ and ___ are boolean literals

A

true and false

25
what happens if you assign a number to bool?
any non zero digit reads true and 0 reads false
26
____ statements executes an action if and only if the condition is true
if
27
what is the syntax for a if statement?
if (boolean-expression) { statement(s); }
28
what is the syntax for an if-else statement?
``` if (boolean-expression) { statement(s)-for-the-true-case; } else { statement(s)-for-the-false-case; } ```
29
you cannot test the equality of two ____ numbers
floating-point
30
what function can you use to generate a random number?
rand( )
31
what header file is rand( ) defined under?
cstdlib
32
what is the value of RAND_MAX?
32767
33
the rand( ) function displays a integer between _____ and ___
0 and RAND_MAX (32767)
34
what is meant when it is said that rand( ) is pseudo random?
the random function produces the same sequence of numbers every time it is executed on the same system
35
when evaluating (p1 || p2) if p1 is true does the program read p2?
no
36
how can you change the seed?
use srand(seed)
37
what header file is srand( ) under?
cstdlib
38
what is a way in which you can get a different sequnce of random numbers every time using the rand( ) function?
use srand with time(0) as the seed
39
what header file is time( ) stored under?
ctime
40
what is the operator for not?
!
41
what is the operator for and?
&&
42
what is the operator for or?
||
43
what does the not (!) operator do?
negates the true to be false and the false to be true
44
what does the and (&&) operator do?
reads true if and only if all the boolean operands are true
45
what does the or (||) operator do?
reads true if any of the boolean operands are true
46
is this correct c++ syntax? | 1<= numberOfDaysInAMonth<=31
no, this would produce a logic error. the following is the correct statement (1<=numberOfDaysInAMonth) && (31 >= numberOfDaysInAMonth)
47
when evaluating (p1 && p2) if p1 is false does the program read p2?
no
48
when evaluating (p1 || p2) if p1 is true does the program read p2?
no
49
a switch statement checks ____ the cases abd executes the statements in the ____ ____
all | matched cases
50
what is the syntax for a switch statement?
``` switch (switch-expression) { case value 1: statement(s)1;break; case value 2: statement(s)2;break; ....... case value n: statement(s)n;break; default: statement(s)-for-default; } ```
51
in switch expressions the variable must always be ____
an integer
52
when the value in a case statement matches the value of a switch expression the statements starting from that case are executed until
either a break statement or the end of the switch statement is reached
53
what is the syntax of a conditional expression for an if else statement
boolean expression ? expression1 : expression 2 | where ? acts as if and : acts else
54
what is the only ternary operator in C++ and why is it a ternary operator
the conditional expression formed by ? and : | it is ternary becayse it uses three operands