Lecture 1 Flashcards

1
Q

What are variables?

A

Variables hold data. They represent storage in memory (size + location)

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

3 Steps of creating a variable

A

Declaration: Introduce the variable name and type
Definition: Reserve space in memory
Initialisation: Assign a known value (e.g. number)

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

What is the arithmetic type and the number of bits of the following data types:
-char
-short
-int
-float
-double

A

char = integer & 8 bits

short = integer & 16 bits

int = integer & 16 or 32 bits

float = Real number & 32 bits

double = Real number & 64 bits

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

Implicit vs Explicit casting?

A

Implicit:
uint8_t = 22;
uint16_t b = a

Explicit:
float c = 3.5;
uint8_t = (uint8_t) c;

*Defining the data type of the cast variable

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

What are these arithmetic operators?
+, -, *, /, %

A

+ = addition
- = subtraction
* = multiplication
/ = division
% = modulus

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

What are these assignment operators?
=, +, -, *, /, %

A

= Assignment
+= Addition assignment
-= Subtraction assignment
*= multiplication assignment
/= division assignment
%= Modulo assignment
a++ post increment (be

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

What are the shift operators equivalent to?

A

Left shift is equal to multiplying by 2

Right shift is equal to dividing by 2

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