W1: Expressions Flashcards

1
Q

How does evaluating expressions work?

A
The ALU (Arithmetic-logic-unit) evaluates the instructions on integer values
The FPA evaluates the instructions on floating-point values.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What expressions can the ALU process on integer types?

A

Arithmetic
Relational
Logical

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

Arithmetic expressions consist of:

A

Integral operands for processing by the ALU

Floating point operands for processing by the FPA

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

What are the binary operations on integral (int and char) operands?

A
operand + operand
operand -  operand
operand * operand
operand / operand
operand % operand - remainder of the division of left by right (division produces a whole number)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are the unary operations on integral operands?

A

+ evaluates to the operand

- changes the sign of the operand

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

What are the binary operations on floating-point operands?

A

operand + operand
operand - operand
operand * operand
operand / operand

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

What are the unary operations for floating-point operands?

A

+ operand evaluates to the operand

- operand changes the sign of the operand

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

What are relational expressions?

A

C language supports 6 relational operations. A relational operation evaluates a condition. It compared two values and produces ‘1’ if the condition is true and ‘0’ if the value is false. The value is a type of int.

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

What are the 6 relational operations?

A

operand == operand: equal in value
operand > operand: left is greater than right
operand >= operand: left is greater than or equal to right
operand < operand: left is less than the right
operand <= operand: left is less than or equal to right
operand != operand: left is not equal to the right

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

What values represent true and false in C language?

A

0 for false

Any other value for true

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

Logical expressions take one of these forms:

A

operand && operand: both operands are true
operand || operand: one of the operands is true
operand ! operand: the operand is not true

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

What is deMorgan’s law?

A

A handy rule for converting conditions in logical expressions

“The opposite of a compound condition is the compound condition with all sub-conditions reversed, all &&s changed to ||s and vice versa”

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

What is a shorthand assignment?

A

Shorthand operators that combine an arithmetic expression with an assignment expression. The arithmetic expression is stored in the left operand.

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

What are the 5 binary shorthand assignment operators for integral operands?

A

Operand (operators) Operand
I += 4, i = i - 4 : add 4 to I and assign to I
I -= 4, I = I - 4: subtract 4 from I and assign to I
*=
/=
%=

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

What are the 4 unary operands for shorthand assignments?

A

++I : increment I by 1
I++
–i: decrement I by 1
I–

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

What are the binary shorthand assignment operators for floating-point operands?

A

*=
/=

17
Q

Unary operands for shorthand assignment operators for floating-point operands

A

++x increment by x
X++
–x decrement by x
X–

18
Q

What is casting?

A

The conversion from one type to another. To convert, make the operand with the target type enclosed within parentheses ( )
Ex. (float) operand

19
Q

The C language uses the following ranking:

A
Long double (higher)
Double
Float
Long long
Long
Int
Short
Char (lower)