What are the 4 number systems and their bases
Binary: 2
Octal: 8
Decimal: 10
Hexadecimal: 16
Conversion: base^(0-7) * binary
The different bases are represented with which symbols
Decimal: none
Binary: 0b
Octal: 0
Hex: 0x
How to convert binary to decimal?
Add up powers of 2
How to convert binary to octal?
Convert every 3 binary bits to octal digit (add within those 3 bits)
(421 421 421)
How to convert binary to hex?
Convert every 4 binary bits to hex digit
(8421 8421)
10-15 is A-F
How to convert any base to decimal?
sum of (base ^ position) * value
How to convert decimals to binary?
divide by 2 get remainder, bottom digit is leftmost bit
How to convert decimals to hex?
divide by 16 get remainder, bottom digit is leftmost digit
What are the sizes of these data types:
- char
- int
- float
- double
- pointer
What are key characteristics of magnitude-only bit model
What are key characteristics of Two’s Complement bit model
What are key characteristics of fixed-point bit model
What are key characteristics of floating point bit model
What are key characteristics of ASCII
What are compound data types, list 3 examples
What does this do: char myString[50];
Declare string (array of char primitives) of size 50 but its uninitialized (filled with garbage characters)
char arr[] = {1, 2, 3}
what is arr
int arr[] = {100, 200, 300, 400};
how to set element at index 2?
arr[2] = x;
*(arr + 2) = x;
(dereference pointer to array identifier incremented by 2)
(remember [] is syntax for dereferencing)
int arr[] = {100, 200, 300, 400};
int *p;
how to set p to element at index 2?
p = &arr[2];
p = arr + 2;
(remember [] is syntax for dereferencing)
What’s the difference between defining variables of type struct with and without typedef?
struct AddressType addr;
vs
AddressType addr;
- with typedef, no need for struct keyword
What are the advantages and disadvantages of unions?
How are structs padded
Padding bytes are added so struct size is multiple of largest field in struct
What are string literals