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/22):
hello.c.
- Program to find roots of a quadratic equation (draft? 9/12):
roots.c.
- Program to sum integers read from standard input (9/19):
sum.c.
- Program to generate random numbers and show distribution when
converted to range (9/19):
rands.c.
- Simple program to test sort function (10/03):
sort-example.c.
- Simple program to demonstrate recursive Fibonacci function (not in class):
fibonacci.c.
- Function to get time of day as a double (not in class):
timer.h.
- Quotient/remainder example (10/10):
quotient-remainder.c.
- String length example (10/10):
string-length.c.
- Program to sum integers read from file (not in class):
sum-from-file.c.
- Program to copy characters from stdin to stdout (10/17):
copy.c.
- Program to copy characters from one file to another (not in class):
copy-file.c.
- Program to echo command-line arguments (10/17):
echo-arguments.c.
- Makefile example (10/31):
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 and use qsort for sorting (4/16):
sort-improved.c.
- Unsorted linked list and test program (11/14):
Source code files
int-list.h.
int-list.c.
test-int-list.c;
makefile
Makefile
(see note below about downloading makefiles).
See makefile for usage notes.
Other files