CS 61C (Fall 2007)

Quiz 1

Two questions, submit as "quiz1".  Due 2:45pm before lecture 8/29/2007.


Submission Instructions

Throughout this semester, you will be using the "submit" command to submit your homework, project and quiz solutions. For those of you new to Berkeley, you do this as follows:

  1. Make a directory in your home directory whose name matches that specified in the assignment.
  2. Copy the file(s) you wish to submit into that directory.
  3. From within the directory, give the command "submit directoryName".
  4. The submit program will ask you which files in the directory should be submitted (you will usually want to submit them all).

To submit your quiz, use the name "quiz1" and fill your answers in to a copy of ~cs61c/files/quiz/1/template.txt.  You should replace the text <answer> with your answer, and <explanation> with your explanation, an explanation is shown below.  The important thing is that the question number be followed by a period, and then the answer, with the explanation on any subsequent lines.  Notice that if you want to put a numbered list in your answers, make sure to put a tab before your numbers so our autograder doesn't misread your explanation as more answers.

1. g
I think the answer is g, despite the fact that that's not an option, because I like to get low quiz scores.
This is a second line of explanation.

2. bar
It's not the answer, it's just where I like to do my work.
	1. This list is part of my explanation, the autograder won't get confused because I used tabs.
	2. I like to make lists.
	3. Oxygen is good.

Any problems with the submit program should be reported directly to cs61c-ta@imail.eecs.berkeley.edu or Greg Gibeling ASAP.



Consider the following program.

#include <stdio.h>
int main ( ) {
	int c;
	while ((c = getchar( )) != 'x') {
		putchar (c);
	}
	return 0;
}

1.

Suppose it is run, and the four-character sequence xpxq is provided as input. What gets output?
  1. There's no output.
  2. x
  3. xx
  4. p
  5. pq
  6. an infinite number of characters
Briefly justify your answer.


2.

Answer the same question assuming that the parentheses around c = getchar ( ) are removed.