Expressions, Operator Precedence, MATHS w1 Flashcards

1
Q

operator for addition

A

+

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

operator for subtraction

A

-

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

operator for multiplication

A

*

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

operator for division

A

/

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

operator for modulus

A

%

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

when we divide integers do we get doubles or integers

A

integers

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

when doubles are divided do we get doubles or integers

A

doubles

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

what does modulus give us

A

what is the remainder on division eg 7%3=1

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

what is the addition component assignment operator

A

+=

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

what is += equivalent to

A

variable=variable+expression

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

eg, calculate {result += 15/3}, assuming result is 7

A

12

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

order of precedence

A
unary prefix
unary postfix
multiplicative
additive
relational
equality
conditional
assignment
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

what are unary prefixes

A

++ –

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

what are unary postfixes

A

+ - (as in negative and positive numbers)

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

what is involved in the multiplicative type

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

what is involved in the additive type

A

+ - (sums)

17
Q

what is involved in the relational types

18
Q

what is involved in teh equality type

19
Q

what is involved in the assignment operators type

A

= += -= *= /= %=

20
Q

what order will this sum be calculated?

int result = 12 + 6 / -4 * 5 - 3

A
  1. negative 4
  2. 6/-4 =-1.5
  3. (6/-4)*5 =-7.5
  4. 12+(-7.5) =4.5
  5. 4.5 - 3 =1.5
  6. =1.5
21
Q

associativity of multiplicative

A

left to right

22
Q

associativity of additive

A

left to right

23
Q

associativity of relational

A

right to left

24
Q

associativity of assignment

A

right to left

25
associativity of equality
left to right
26
associativity of conditional
right to left
27
associativity of prefixes
right to left
28
how can we avoid using precedence and making mistakes
brackets
29
what is casting
changing the representation of a value form integer to double or vise versa
30
hpw to import mathematical functions
.math
31
operator for absolute value
abs
32
what is absolute value
number positive version
33
square root function
sqrt
34
power function
pow(value, power)
35
sin function
sin
36
tangent funtion
tan
37
cosine function
cos
38
inverse cos function
acos