Answers
Pointer - CORRECT ANSWER -variable that contains the address of a variable
-void * (pointer to void) is the type of a generic pointer
k&r 5.1-93
p=&c; - CORRECT ANSWER -assigns the address of c to the variable p and p points
to c
-& can only be applied to objects in memory
-* is dereferencing operator, when applied to pointer it accesses the object the
pointer points to
Is 0 a valid address for data in C? - CORRECT ANSWER NO, memory can range
from 0 to (2^64)-1 but not all is valid
k&r 5.4-116
can pointers be compared? - CORRECT ANSWER - yes under certain
circumstances, if p and q point to members in the same array then ==, !=, <=, >=
etc work properly
- p<q is true if p points to an earlier member of the array than q does
k&r 5.4
what automatic conversions do we have? - CORRECT ANSWER those that convert
a narrower operand into a wider one without losing information, such as a int to a
floating point
k&r 2.7-43
One subtle point about the conversion of characters to ints? - CORRECT ANSWER
the language doesnt specify whether the variables of type char are signed or
unsigned
k&r 2.7
Are non-zero values true or false? - CORRECT ANSWER true
k&r 2.7
, Main reason for using floats? - CORRECT ANSWER to save storage in large arrays
k&r 2.7
how do you cast a type? - CORRECT ANSWER (type-name) expression
the expression is converted into the named type
sqrt((double) n)
the cast produces the value of n in the proper type, n itself is not altered
k&r 2.7
length of string? - CORRECT ANSWER length of string plus one more to consider '\
0'
k&r 2.7
how to access a 2D array - CORRECT ANSWER array[a][b]
k&r 5.7
passing a 2D array into a function - CORRECT ANSWER These are all the same
f(int array[a][b]){}
f(int array[][b]){}
f(int (*array)[b]){}
for the last one since [ ] has higher precedence than * without parenthesis it
wouldn't mean the same thing
k&r 5.7
What is a structure? - CORRECT ANSWER collection of one or more variables,
possibly of different types, grouped together under a single name for convenient
handling
k&r 6.1
what are the variable names in structures called? - CORRECT ANSWER Members
k&r 6.1
how is a member of a particular structure referred? - CORRECT ANSWER
structure_name.member
or
structure_name->member