Home
Syllabus
Homework
Example Code
Notes
Links
Introductory Examples for C
Sorting examples:
sorting.c
Macro examples:
macro.c
Computing Fibonacci numbers using recursion and iteration:
fib.c
Using a structure to create a deck of cards:
structex.c
Finding palindromes:
palindrome.c
Printing random numbers:
rand_nums.c
Printing random numbers using a seed:
rand_nums_seed.c
Tic Tac Toe:
TicTacToe.h
,
TicTacToe.c
,
tttmain.c
,
makefile.ttt
Examples from the book
Practical C Programming
by Steve Oualline (available in the library):
examples.tar
Shared memory examples based upon examples from Chapter 3 of the Operating Systems text:
shmem_producer.c
,
shmem_consumer.c
2D Array Allocation and Deallocation example:
array2DExample.c
Prim's Algorithm:
prim.c
Floyd's Algorithm:
floyd.c
Input for Prim's and Floyd's Algorithm:
prim.in
Iterative FFT Example:
iterFFT.c
Recursive FFT Example:
recFFT.c
Inputs for FFT Algorithm:
fft1.in
fft2.in
fft3.in
OpenMP and PThreads Examples
Thread addition:
thread_add.c
Race Condition Example:
rc_broken.c
Semaphores Example:
rc_fixed.c
Serial Array Addition Example:
arrayAdd.c
Serial Finding Minimum Example:
findMin.c
Recursive Finding Minimum Example:
findMinRec.c
Recursive Summation Example:
findSumRec.c
OpenMP Array Addition First Try:
ompArrayAdd.c
OpenMP Parallel For Long Form:
ompArrayAdd2.c
OpenMP Parallel For Short Form:
ompArrayAdd3.c
OpenMP Critical Section Example:
OMPCriticalEx.c
OpenMP Fixed Critical Section Example:
OMPCriticalFixed.c
OpenMP Min Reduction:
ompReduction.c
OpenMP Sum Reduction:
ompReductionSum.c
Semaphores Example:
rc_fixed.c
Producer Consumer Example Using Threads:
prodcons.zip
Dining Philosophers Example:
philosophers.c
OpenMP Dining Philosophers Example:
ompPhilosophers.c
Condition Variable and Scheduling Example:
ConditionVariable.c
Serial Prefix Sum:
serialPrefixSum.c
Serial Hillis and Steele Scan:
serialScan.c
OpenMP Hillis and Steele Scan:
naiveParallelScan.c
Serial Blelloch Scan:
blellochScan.c
Serial Quick Sort:
quicksort.c
Naive OpenMP Bitonic Sort:
bitonicSort.c
MPI Examples
MPI (Message Passing Interface) Send/Receive example:
message_passing.c
MPI Non-blocking send and receive example:
messages_nb.c
Multiple message MPI_Wait Non-blocking send and receive example:
many_messages.c
Multiple message MPI_Waitall Non-blocking send and receive example:
many_messages2.c
MPI Producer Consumer Example:
MPIprodcons.zip
MPI Dining Philosophers Example:
mpiPhilosophers.c
MPI-IO Example:
MPI_IO.zip
MPI Broadcast Example:
bcast.c
MPI Gather Example:
gather.c
MPI Scatter Example:
scatter.c
MPI Reduce Example:
reduce.c
MPI 3D Point Reduce Example:
reduce3D.c
MPI Odd-Even Sort Example:
oddEvenSortMPI.c
MPI Odd-Even Sort Example:
oddEvenSortMPI_Deadlock.c
MPI Odd-Even Sort Example:
oddEvenSortMPI_PossibleDeadlock.c
In-class Ring Example:
ring.c
MPI Quicksort Example:
quicksortMPI.c
MPI FFT Example:
iterFFTMPI.c