List of the HW#3 Function Descriptions
Here are the HW#3 functions pictured in the static call graph along
with descriptions of how each of them works. Note that
main
is not listed. main
implements the
overall purpose of the assignment using the first five functions.
printHeader
- Prints the header for the program.
printFooter
- Prints the footer for the program.
printAnswer
- Prints an appropriate message depending on the answer (prime or
not prime) passed.
getWordNum
- Reads a word (base 36 number) from standard input and returns its
base 10 value. If the word starts with a
0
, immediately returns
WORD_NUM_SENTINEL
.
isPrime
- Returns whether the given number is prime.
getDigit
- Reads a digit from standard input and returns it. Exits on
malformed digits (although it accepts
'\n'
).
isValidDigit
- Checks whether the digit is valid in the current
BASE
.
addDigit
- Starting with the number passed, adds on the passed digit as the
next digit in the number. So, for example, the number might contain the value of AR (i.e., 387 in base 10) and the digit might be
'4'
. So, we shift
the number over (AR0 in base 10 is 387 * 36 == 13932) and add the
value of the digit (4) to get 13936. Returns the resulting
value. Exits on overly large words.
getNumFromDigit
- Given a digit in
BASE
, returns its numerical value.
isDivisibleBy
- Returns whether the given number is divisible by the given divisor.