Assignment 1, due Jan 20
Part of
the homework for 22C:60 (CS:2630), Spring 2012
|
On every assignment, write your name legibly as it appears on your University ID card! Homework is due on paper at the start of class on the day indicated (usually Friday). Exceptions will be made only by advance arrangement (excepting "acts of God"). Late work must be turned in to the TA's mailbox (ask the CS receptionist in 14 MLH for help). Never push homework under someone's door!
int funct( int i ) { if (i > 3) { i = funct(i - 2) + funct(i - 3); } return i; }
Problem: Make a table of the values of funct(i) for values of i ranging from 0 to 10. (1 point)
char digit_a( int i ) { const char digits[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'}; return digits[i % 10]; } char digit_b( int i ) { return (i % 10) + '0'; }
a) For what values of the parameter i would you expect these functions to return different values, and for what values of i do they return the same thing? (1 point)
b) For the values where these two functions agree, what do they do? (1 point)