Lecture 4 Flashcards

Conditions, Logical Expressions and Selection

1
Q

What is a condition?

A

A logical expression which are either true or false

E.g.
if condition is true then
execute block1
else condition is false then
execute block2

OR

while condition is true
Repeat executing block1

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

What is combined to make a condition?

A
  • Relational Operators
  • Logical Operators
  • Other variables, constants, literals,..
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are relational operators?

A

< less than
<= less than or equal
> greater than
>= greater than or equal
== identically equal to
!= not equal to

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

What is a branch?

A

An if statement

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

What is a one way branch?

A

if

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

What is a two way branch?

A

if-else

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

What is a multi-way branch?

A

if-else if-else

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

What is used to store true or false values?

A

bool

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

What does ! represent?

A

Is the NOT operator it is unary, the reversing of the value of a logical expression

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

What are combine conditions?

A
  • && - AND
  • || - OR
  • ! - NOT
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is &&?

A

A binary boolean operator, both operands have to be true for the result to be true

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

What is ||?

A

A binary boolean operator, at least one of the operands have to be true for the result to be true

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

(What is !) ?

A

A unary boolean operator, if the operand is true the result is false

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