Comments | Online Safety | Help
  Here are some sample programs written in the C programming language. Code is added on a regular basis so keep checking back for more. There is more C code available at the following locations on this site - C&G 424 Project, C&G 425 Project and Portfolio.  
     
 
Useful 'C' Code Links :
     FAQ about UNIX Programming
     A web site designed to help you learn C or C++
     The GNU C Library
     comp.lang.c FAQ
     The official home page for Advanced Linux Programming
     C++ FAQ
     FREE Development Environment (instructions)
     MinGW Compiler
     Bloodshed Software
     Borland Museum
 
Some of my notes on the following subjects
     Pointer arithmetic
     Binary Files

     Text Files

     Double Linked Lists [zenithpaints]
 
 
 
A program that converts an inputted fraction in the form of - 1/2 - into it's decimal representation. For example entering - 3/4 - will return - 0.75
This code shows the functions scanf() and printf() in action. Also shows casting in action, although a simple example.
  This program calculates a workers wages and overtime for a given week worked. It requests various input form the user then displays the workers wages. The overtime is calculated at 1.25 times the hourly rate.
A simple program showing some of C's arithmetic operators in action. Also shows the functions scanf() and printf() again.
 
   
This program calculates a workers wages and overtime for a given week worked it extends the previous overtime.c code by deducting tax and national insurance from the workers wage. The tax and national insurance calculation is in a basic form and is only used to demonstrate the principle behind such a calculation.
A simple program showing some of C's arithmetic operators in action and the use of Constants by using the #define preprocessor. Also shows the functions scanf() and printf().
  This program will calculate the day-of-the-week for a specified date between the following dates 01:01:1800 - 31:12:1999 (Y2K BUG :-)). It demonstrates various c programming constructs - the - if, else - selection construct and also the - switch, case - selection construct.
Again it uses the very popular printf() and scanf() functions for displaying and retrieving information respectively.
     
This program lets you play that well know game of hangman. Firstly a player enters a word to be guessed, another player now has to guess this word one letter at a time. The other player is allowed 10 incorrect guesses after which time the word is revealed to them. The most popular bit of code ... must be set as home work a lot =)) Find the Hurkle is a game where the computer generated two random numbers, these are the coordinates where the Hurkle is hiding. The player has 10 attempts at finding the Hurkle. At every incorrect guess the player is informed if their guess was too high or too low.
     
 
This program determines the number of each monetary denomination that would need to put in an employee's wage packet. The employee's wage is input by the user, if the user enters 0 the program will terminate.   This program computes the driving time for a given distance and speed input by the user. (Miles and mph)
     
 
Well this is just a quick program I wrote for where I work. Actually this was one of my very first c programs. Found it on a dusty old floppy the other day so I decided to have a go at tweaking it. Now incorporates structures and pointers etc... Take a look if you got nothing better to do =))   Program that takes the contents of an amend file and updates a stock file. Any stock quantity that falls either above or below a certain limit is also added to a query file. Demonstrates text file access, and sequential file access.
     
checksum.c - code
executables for [ DOS ] [ LINUX ]
 
Performs a modulus 11 check digit check, either a 5 or 6 digit value. The 5 digit weighting value = 5432 and the 6 digit = 65432. A check digit of X is used to represent a subtraction of zero, and 0 is used to represent a subtraction of 1.   Will recursively display the contents of a given directory (and every dir in that directory etc...). This is a Linux only program, so do not try executing it on a Win box. Displays what kind of file the displayed file is (reg file, exe, block, char ...).
     
MORE C CODE AVAILABLE
Checks to see if the given file exists and that it can be opened for write access and read access. Does not read or write to the file, just displays on screen if successful or not. This code is once again for Linux only.   There is more c code located in the portfolio section of this site, and also on zenithpaints.co.uk, where my full code and documentation is hosted for the C&G 424 and 425 projects.