Tom Kelliher, CS17
Apr. 29, 1996
Professor Levish enlightens us on the nature of the existential semicolon in the while and do/ while constructs.
We will discuss arrays and files on Friday.
We'll also have a surprise quiz on Friday.
A recursive function:
Any function which calls itself, directly or indirectly, is called a recursive function.
What prevents a recursive function from infinitely recursing?
Requirements for recursion:
void print(int n) { if (n > 0) { print(n - 1); cout << n; } }
Does it meet the requirements?
What happens if we swap the statements in the if block?
How does this work?
int fact(int n) { assert (n >= 0); // Use assert.h. if (n < 2) return 1; else return n * fact(n - 1); }
Does it meet the requirements?
How does this work?
Ranges, defaults for signed, unsigned?
Ranges, precisions? ((6, 38), (19, 4,932)).