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 (9/13):
hello.c.
- Program to find roots of a quadratic equation (9/20):
roots.c.
- Simple program to test sort function (9/27?):
sort.c.
- Program to copy characters from stdin to stdout (10/04):
copy.c.
- Program to copy a file (not in class):
copy-file.c.
- Program to echo command-line arguments (not in class):
echo-arguments.c.
- Program to read numbers from a file, double them, and write
results to a file (not in class):
copy-and-double.c.
- Program to get and echo text input, line by line (not in class):
echo-lines.c.
- Slightly improved simple program to test sort function (10/18):
sort-improved.c.
(Also demonstrates use of function pointer with qsort.)
- Unsorted linked list and test program (10/25):
- Simple examples of parallel programming (11/22):
- POSIX threads:
- MPI:
- OpenMP:
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").