CSCI 1120 (Low-Level Computing):
Sample Programs
Disclaimer: Code linked from this page is intended as a
cleaned-up and commented version of examples from class.
Many programs could be further improved with
regard to functionality or design, but then they would
no longer be as close to what we did in class.
Programs
- "Hello, world" program (8/29):
hello.c.
- Program to find roots of a quadratic equation,
preliminary version (9/19):
roots.c.
- Program to sum integers (9/26):
sum.c.
- Program to convert Julian date to month/year (9/26,
with additions/corrections):
julian.c.
- Simple program to test sort function (10/10):
sort.c.
- Simple program to demonstrate recursive Fibonacci function (10/10):
fibonacci.c.
- Function to get time of day as a double (not in class):
timer.h.
- Quotient/remainder example (10/17):
quotient-remainder.c.
- Array access using pointers (10/17):
arrays-with-pointers.c.
- Pointer demo (10/17, revised):
pointer-demo.c.
- Program to copy characters from stdin to stdout (10/31, briefly):
copy.c.
- Program to echo command-line arguments (10/31):
echo-arguments.c.
- Program to echo command-line arguments and say whether they can
be integers (10/31):
echo-arguments-plus.c.
- Program to sum integers read from file (11/14):
sum-from-file.c.
- Makefile example (11/14):
Source code files
defs.h,
foobar.c,
foobar.h,
main.c;
makefile
Makefile.
- Program to test sort function, improved to get number of elements from
command-line argument (11/21):
sort-improved-1.c.
- Unsorted linked list and test program (11/21, 11/28):
- Program to test sort function, improved to get number of elements from
command-line argument and use qsort for sorting (11/28):
sort-improved-2.c.
Other files
- Sample makefile Makefile
for compiling C programs.
Note:
To obtain a makefile, use your browser's download function;
cutting and pasting will likely turn the tabs in the makefile
into spaces and cause it to not work.
Put the makefile in the directory in which you want to
compile.
All the makefiles linked from this page begin with
brief documentation on their use (the "usage examples").