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.
- Very simple example of variables, expressions, I/O
(similar to example from 8/29):
simple-io.c.
Revised to check for input errors (9/05):
simple-io-with-check.c.
- Simple examples of functions (9/05):
simple-fcn.c,
factorial.c.
- Simple example of while loop (9/12):
whilesum.c.
- Simple example of for loops and array (9/12):
silly-array.c.
- Simple example of function with pointer arguments (9/19):
divide.c.
- Starter sort program (not in class):
sorter-start.c.
- Simple example of working with strings, various ways (9/26):
simple-strings.c.
- Program to get and echo a line of text (not in class):
echo-line.c.
- Program to echo command-line arguments (9/26, 10/03):
echo-args.c.
- Program to echo text one character at a time (not in class):
echo-text.c.
- Program to copy one file to another (10/03):
copy-file.c.
- Program to sum integers read from file (10/03):
whilesum-fromfile.c.
- Improved (and complete) sort program (10/10):
sorter-improved.c.
- "Floating point is strange" examples (10/17):
strange-float-1.c,
strange-float-2.c.
- Simple example of function with function-pointer parameter (10/24):
function-pointer.c.
- Makefile example (10/24):
Source code files and Makefiles
here.
- Two ways to make dynamically allocated 2D arrays (10/31):
two-D-array.c.
- Simple example of struct (simplified bank account) (11/07):
simple-struct.c.
- Linked-list example (11/07, 11/14):
Source code files and Makefile
here.
- Program illustrating how sizes of data types can vary (11/28):
sizes.c.
Other files