Assignment 1, due Jan 25
Part of
the homework for 22C:60 (CS:2630), Spring 2013
|
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 ) { /* warning! This is not the fibonacci series */ if (i > 1) { i = funct(i - 1) - funct(i - 2); } 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 Question: These functions do essentially the same thing for non-negative values of i. Why do they behave very differently for negative values? (1 point)