You need to have an EECS instructional account (cs61c-*) in order to do your lab work. More importantly, you will need to log in to this account in order to enroll in the class. Don't forget to change your password (passwd) once you have logged in.
Copy the contents of ~cs61c/labs/01 to a suitable location in your home directory.
$ mkdir ~/lab01
$ cp -r ~cs61c/labs/01/ ~/lab01
Fill in the blank in the following C program, also in output0.c, so that its output is a line containing 0. Don't change anything else in the program.
#include <stdio.h>
int main(void) {
int n;
n = ___;
printf("%c\n",n);
return 0;
}
To verify your solution, compile it and run the resulting binary:
$ gcc -o output0 output0.c
$ ./output0
0
Checkoff: Explain the change you made to output0.c.
Look at the code contained in eccentric.c. We see four different examples of basic C control flow. First compile and run the program to see what it does. Play around with the initialization values of the control variables i, j, k, and m and see how that changes the program output. Modifying only the initialization values of variables, make the program produce the following output:
$ gcc -o eccentric eccentric.c
$ ./eccentric
Berkeley eccentrics:
====================
Happy Happy Happy
Yoshua
Go BEARS!
Checkoff: Explain the changes you made.
Bonus: If you are allowed to replace appearances of the control variables (i,j,k,m) with each other in the code, what is the minimum number of variables you could use to produce the same output above?
In class we discussed number representation. In particular, we discussed unsigned integers and two's complement, the most commonly used format for signed integers. Look at biggestInt.c. You may wish to read through the comments, but at this point it is not critical that you understand exactly how the program works. (Basically, it is a C program that will tell you some useful information about certain C data types. It does this by exploiting the fact that C does not check for overflow and wrap around conditions.)
Compile and run the program and answer the following questions:
Checkout: Give your answers to the above four questions to the TA.