Sample C Programs for CS 1713 Section 3
Here are some of the programs presented in class, as well as solutions
to some of the programming assignments.
- balance.c
- Check for balanced curly braces in a C program.
- cat.c
- Print the file named on the command line to standard output.
- complex.c
- Represent complex numbers in C as an abstract data type.
- complex.h
- Header file to accompany complex.c
- fact.c
- Program to print factorials of 0 through 13 using a function.
- fib.c
- Program to print the first 21 Fibonacci numbers using a function.
- findstring.c
- Program that prints all occurences of string in the the first
command line argument in the file named by the second command line argument.
- funcs.c
- Examples of using void functions.
- genfsa.c
- An early version of the program to generate Finite State Automata
from your login name (somewhat advanced).
- max.c
- Program to print the maximum number in a file called numbers.
- reverse.c
- Read in a string and print it backwards, using a void function.
- rover.c
- Instructors solution to Assignment 4.
- sd.c
- Find the mean and standard deviation of numbers in a file
called numbers
- search-sort.c
- Do timings on linear search, binary search, insertion sort, and
qsort (a version of quick sort).
- sieve.c
- Sieve of Erasthones: print out prime numbers from 2 through 1000
by sieving out the composites.
- string.c
- Use a function to print the value of the first decimal integer
in a string, without using scanf().
- students.c
- Read in a list of students IDs and scores, giving the weighted
average for each student and the average for the best student.
- fsa.c
- Read in a description of a Finite State Automaton, and then check
to see if the string on the standard input is accepted.
- circle.c
- Draw circles on the screen using 2D arrays
- matrix.c and
matrix.h
- An abstract data type using typedef and struct
that implements a matrix data type with bounds checking.
- wordfreq.c
- A program that prints the twenty most frequent words in the
file on the standard input. Try it on William Shakespeare's
King Henry VIII .
- life.c
- Instructor's Game of Life