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 (2/15):
hello.c.
- Program to find roots of a quadratic equation (2/15, 2/22):
roots.c.
- Program to test sort function (3/08):
sort.c.
- Program to count upper-case characters in string,
as an example of a function operating on a string (3/08):
count_upper_case.c.
- Program to compute quotient and remainder, as an example of
getting input from the user and of a function with pointer
parameters (3/29):
divide.c.
- Program to add a series of numbers (3/29):
add-numbers.c.
- Program to echo command-line arguments (4/05):
echo-arguments.c.
- Program to copy a file (4/05):
copy-file.c.
- Program to add a series of numbers, reading from and writing to
files (4/05):
add-numbers.c.
- Slightly improved simple program to test sort function (4/19):
sort-improved.c.
(Also demonstrates use of function pointer with qsort.)
- Program demonstrating use of struct (4/19):
struct-example.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").