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/14):
hello.c.
- Program to find roots of a quadratic equation (9/21):
roots.c.
- Simple program to test sort function (9/28):
sort.c.
- Program to copy characters from stdin to stdout (10/05):
copy.c.
- Program to echo command-line arguments (10/26):
echo-arguments.c.
- Program to copy a file (10/26):
copy-file.c.
- Program to read numbers from a file, double them, and write
results to a file (10/26):
copy-and-double.c.
- Program to get and echo text input, line by line (10/26):
echo-lines.c.
- Slightly improved simple program to test sort function (11/23):
sort-improved.c.
(Also demonstrates use of function pointer with qsort.)
- Unsorted linked list and test program (11/23):
- Program to display internal representation of floating-point
number (12/07):
show-float.c.
- Programs demonstrating simple uses of ncurses library
(12/07):
show-float.c.
- Programs demonstrating OpenMP for multithreading (12/07):
- Additional simple examples can be found among these
sample programs for CSCI 1320.
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").