The C Programming
Language
References
Examples
Examples marked by the
symbol contain slightly more
advanced material and will not be shown in class.
|
Performs arithmetic calculations on the
input numbers. |
|
|
Performs bitwise manipulations on the input
numbers. |
|
|
Reads a integer and prints its sign and it
parity (whether it is even or odd). |
|
|
Reads a Roman digit, and prints out its
numerical value. |
|
|
Reads two integers and computes their
greatest common divisor using |
|
|
Reads two integers and computes x^y (x
raised to the power of y). |
|
|
Prints out the multiplication table. |
|
|
Approximate the square-root of the input
number using the ancient Babylonian technique. |
|
|
Reads an integer and determines whether it
is prime. |
|
|
Reads a sequence of grades (terminated by
-1) and computes their average and variance. |
|
|
Reads a sequence of grades (terminated by
-1) and computes their average and variance. Aborts in case of a -2
input. |
|
|
Reads two integers n and k, and computes (n
over k), the number of different sub-sets of size k one can choose from
a set of size n. |
|
|
Reads two points and computes the Euclidean
distance between them. |
|
|
Reads two points and computes the distance
between them using several l_k norms. |
|
|
Prints a power of tables. |
|
|
Read two input strings and find their
longest common prefix. |
|
|
Computes an approximation to the value of pi. |
|
|
Replaced all the letters in a text line
using a replacement table. |
|
|
Converts a number in base 26 to its decimal
value. |
|
|
Checks Stirling's formula for evaluating
ln(n!). |
|
|
Reads three integers and computes (x^y) mod
m. |
|
|
Solves the problem of the towers of Hanoi. |
|
|
Computes the real-valued solutions of a
quadratic equation. |
|
|
Reads a string an reverses it. |
|
|
Performs bubble-sort on an array of integers. |
|
|
Reads two input strings and prints all the
occurrences of the second string within the first one. |
|
|
Answers queries on a sorted array of random
integers. |
|
|
Reads an input file and prints out a
histogram of all the letters it contains. |
|
|
Converts a file to upper (or to lower) case. |
|
|
Enciphers or deciphers a file using a
cumulative xor formula. |
|
|
Reads a sequence of grades and computes
their average and standard deviation. |
|
|
Reads the user's first and last name and
prints a greeting. |
|
|
Picks up five cards and prints them. |
|
|
Reads a date and prints the dates of the
days before and after it. |
|
|
Picks up five cards and prints them
(improved version). |
|
|
Reads a date and prints the dates of the
week after this date. |
|
|
Reads a series of input points, computes
their centre of mass and locates the points closest and farthest from
the centre. |
|
|
Reads an input file called shapes.txt, analyzes it and computes the area
of each shape it specifies. |
|
|
Reads a sequence of observations (real
numbers) and prints the deviation of each observation from the mean. |
|
|
A package for maintaining doubly-linked
lists of real numbers. |
|
|
Tests the functionality of the doubly-linked
list package (compile with list.c). |
|
|
Sorts a list of numbers using the merge-sort algorithm. |
|
|
Read an input file called cities.txt containing city entries, and prints
the cities sorted by their name and by population. |
|
|
A package for generic binary trees. |
|
|
Constructs a tree of random integers and
lets the user execute interactive commands on it (compile with
tree.c). |
|
|
Reads an input file and counts the number of
occurrences of the words in it (compile with tree.c). |
Appendices