Assignment 1, due Jan 20

Part of the homework for 22C:60 (CS:2630), Spring 2012
by Douglas W. Jones
THE UNIVERSITY OF IOWA Department of Computer Science

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!

  1. What is your E-mail address? (probably firstname-lastname@uiowa.edu, but this does not always work, for example, douglas-jones@uiowa.edu is not teaching this course.)

    Homework questions based on prerequisite material:

  2. Background: Consider this function in C (but C++, Java and C# look very similar):
    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)

  3. Background: Consider these functions in C (but C++, Java and C# look very similar):
    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)

    Homework questions based Chapter 2 of the text:

  4. A Problem: Give the 7-bit ASCII representation of the text "Spring 2012" Don't include the quotes. Give your result as a column of binary numbers. (1 point)