Title: CSE 351 23au / LS3 Memory & Data II

Q: In a box-and-arrow diagram, variables are represented as ___, and stored addresses are represented through ___
A: boxes, arrows
ex: int* p = &x;

Q: In pointer arithmetic, we scale by the size of the _____ that we’re pointing to
A: data type

Q: True or False: Given two pointers p1 and p2 of the same data type, the result of p2-p1 gives us the number of elements (of that data type) between the two addresses
A: True!

Q: What symbol is used to retrieve the address of a variable?
A: & ('ampersand')
The statement int* p = &q allows us to set p to the address of q using the '&' symbol

Q: Arrays are sets of ______ locations in memory that store the same types of data
A: contiguous
In memory, array elements are stored right nex tto each other (contiguously).

Q: Dereferencing an array using *(a+1) is syntactically equivalent to ___
A: a[1]

Q: Given an array of m elements each with a size of n bytes, how many bytes of contiguous memory will be allocated?
A: mn or specifically, num*sizeof(type)

Q: True or False: The statement a[-1] is valid in C (valid as in the program still executes)
A: True, although this can often lead to logical errors or bad memory accesses

Q: In C, Strings are always terminated by the ___ character
A: null (\0)

Q: True or false: The string literal “cse351” takes up 6 bytes of memory
A: False, the null terminator character (\0) is implicitly the 7th byte that is allocated at the end

Q: In C, a string literal is automatically stored in memory as an ___
A: Array of characters