Lecture 1 Flashcards
What are variables?
Variables hold data. They represent storage in memory (size + location)
3 Steps of creating a variable
Declaration: Introduce the variable name and type
Definition: Reserve space in memory
Initialisation: Assign a known value (e.g. number)
What is the arithmetic type and the number of bits of the following data types:
-char
-short
-int
-float
-double
char = integer & 8 bits
short = integer & 16 bits
int = integer & 16 or 32 bits
float = Real number & 32 bits
double = Real number & 64 bits
Implicit vs Explicit casting?
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
What are these arithmetic operators?
+, -, *, /, %
+ = addition
- = subtraction
* = multiplication
/ = division
% = modulus
What are these assignment operators?
=, +, -, *, /, %
= Assignment
+= Addition assignment
-= Subtraction assignment
*= multiplication assignment
/= division assignment
%= Modulo assignment
a++ post increment (be
What are the shift operators equivalent to?
Left shift is equal to multiplying by 2
Right shift is equal to dividing by 2