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

A

< <= > >=

18
Q

what is involved in teh equality type

A

== !=

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
Q

associativity of equality

A

left to right

26
Q

associativity of conditional

A

right to left

27
Q

associativity of prefixes

A

right to left

28
Q

how can we avoid using precedence and making mistakes

A

brackets

29
Q

what is casting

A

changing the representation of a value form integer to double or vise versa

30
Q

hpw to import mathematical functions

A

.math

31
Q

operator for absolute value

A

abs

32
Q

what is absolute value

A

number positive version

33
Q

square root function

A

sqrt

34
Q

power function

A

pow(value, power)

35
Q

sin function

A

sin

36
Q

tangent funtion

A

tan

37
Q

cosine function

A

cos

38
Q

inverse cos function

A

acos