Assignment 1, due Feb 1

Solutions

Part of the homework for 22C:112, Spring 2008
by Douglas W. Jones
THE UNIVERSITY OF IOWA Department of Computer Science

  1. Background: Consider the concept of transparency, as discussed in the notes for lecture 1. One of the reasons that computer viruses are so common in the Microsoft realm is that the macro extension language of Microsoft Word, Visual Basic, is too transparent. Virus writers use this transparency to so that, when an infected Word document is opened, it reaches out and searches for other documents to infect.

    Question: The transparency of the macro extension language of Microsoft word was quite deliberate. Why would a word user want access to the full power of Visual Basic from within a word document? (0.5 points)

    For example, consider a document that is a business form, where filling in the form causes automatic side effects such as filling in other blanks in the form, where filling in those blanks could involve retrieval of items from a database. Take a purchase-order form and fill in the part number you want to purchase, and it automatically fills in the price and computes the shipping weight and postage.

  2. Background: Take a look at the Multics History Web Site http://www.multicians.org/history.html to answer the following (0.1 points each):

    a) What was the name of the timesharing system that was the predecessor of Multics at MIT?

    CTSS, the Compatable TimeSharing System.

    b) Why did Bell Labs quit the Multics project?

    It was overly ambitious, and as a result, it took too long for the project to produce an economical useful system.

    c) What came of the effort to port Multics to the Intel x86 family?

    Nothing, neither with Sequent corporation (which made x86-based multiprocessors), nor with Honeywell-Bull.

    d) What was the last Multics site?

    It was at the Canadian Department of National Defense in Halifax.

    e) In what sense is Multics an open-source product?

    In November, 2007, Bull released the source completely license free.

  3. Background: Note the following manual of style for C programmers: http://homepage.cs.uiowa.edu/~dwjones/syssoft/style.html and note that the following C program does not conform to this style.
    #include <stdio.h>
    int fib(int i){if(i<=1){return i;}else return
    fib(i-1)+fib(i-2);}int main(){int i; for(i=1;i<=
    10;i++){printf("fib(%d)=%d\n",i,fib(i));}}
    

    a) Fix it so it conforms to the recommended style. (0.5 points)

    /* fib.c */
    /* program to print the first 10 consecutive Fibonacci numbers */
    
    #include <stdio.h>
    
    /* Recursive routine to compute the ith Fibonacci number */
    int fib( int i )
    {
            if(i <= 1) {
                    return i;
            } else {
                    return fib( i - 1 ) + fib( i - 2 );
            }
    }
    
    /* Main program */
    int main()
    {
            int i;
            for( i = 1; i <= 10; i++ ) {
                    printf( "fib(%d)=%d\n", i ,fib(i) );
            }
    }
    

    a) Run it and show the output. (0.5 points)

    fib(1)=1
    fib(2)=1
    fib(3)=2
    fib(4)=3
    fib(5)=5
    fib(6)=8
    fib(7)=13
    fib(8)=21
    fib(9)=34
    fib(10)=55
    
  4. Background: In the Unix (and Linux) shell, consider the following one-line shell command:
    echo echo Hello World > qzzbzzq ; sh < qzzbzzq ; rm qzzbzzq
    

    a) What output does it produce (0.5 points)

    Hello World
    

    a) How does it produce this output? (0.5 points)

    It first uses the echo command to copy the command echo Hello World to the file qzzbzzq and then it starts a shell to execute the commands in this file. Executing the echo command in this file produces the output, and then the execution of the original line completes, deleting the file.