Advanced Programming Lab 1
Advanced Programming Lab 1
Submission
----------Please refer to the lab retrieval and submission instruction, which outlines
the only way to submit your lab assignments. Please do not email me your
code.
If a lab assignment consists of multiple parts, your code for each part must
be in a subdirectory (named "part1", "part2", etc.)
Please include README.txt in the top level directory.
README.txt should contain the following info:
-
At a minimum,
your name
your UNI
lab assignment number
description of your solution
Makefile
--------If a part asks for a program, you must provide a Makefile. The TAs will
make no attempt to compile your program other than typing "make".
The sample Makefile in the lecture note is a good starting point for the
Makefile you need to write for this lab. If you understand everything about
the sample Makefile, you should have no problem writing this labs Makefile.
Here are some additional documentations on Make:
- Stanford CS Education Library has a nice short tutorial on
Makefiles. See Unix Programming Tools, Section 2, available at
http://cslibrary.stanford.edu/107/.
- The manual for make is available at
http://www.gnu.org/software/make/manual/make.html. Reading the
first couple of chapters should be sufficient for basic
understanding.
There are a few rules that we will follow when writing makefiles in
this class:
- Always provide a "clean" target to remove the intermediate and
executable files.
-1
4294967295
ffffffff
1111 1111 1111 1111 1111 1111 1111 1111
$ ./convert
256
signed dec:
unsigned dec:
hex:
binary:
256
256
100
0000 0000 0000 0000 0000 0001 0000 0000
There is a bash shell trick that you might find useful for testing your
program. You can evaluate an arithmetic expression like this:
$ echo $(( 1 + 2 + 3 ))
6
In addition, you can take the output of one program, and feed it as a user
input to another program by chaining the two programs with | character.
So, you can input the minimum 32-bit integer like this:
$ echo $(( -2
signed dec:
unsigned dec:
hex:
binary:
Note that your program must behave EXACTLY the same as the sample runs shown
above. Given the same number, your program must generate the EXACT same
output--same order, same strings, same spacing.
To help you get started, I gave you a little C program called printf-test.c
in the lab 1 skeleton code. Please take a look at it. Good luck!