Category Archives: Uncategorized

Normal Distribution

One of the most useful bits of number-crunching you can do with data is to calculate the probability distribution, in the earnest hope that it will be a reasonable fit for one of the recognised distributions such as the normal … Continue reading
Posted in Uncategorized | Leave a comment

Calculating Great Circle Distances

The shortest distance between two locations on the surface of Earth (or any planet) is known as the Great Circle Distance. Except for relatively short distances these cannot be measured on a map due to the distortion and flattening necessary … Continue reading
Posted in Uncategorized | Leave a comment

Graphing Data Using a Logarithmic Plot

The majority of data can easily be plotted on a graph with equal intervals on the axes, for example 1, 2, 3 or 100, 200, 300 etc.. Some data, typically that which increases or decreases exponentially, cannot comfortably be graphed … Continue reading
Posted in Uncategorized | Leave a comment

Now on Github

A very quick micro-post just to say that I have pushed the source code for all my posts to date to Github. The URL is https://github.com/code-in-c The source code for all future posts will also be on Github so feel … Continue reading

Posted in Uncategorized | Leave a comment

File Byte Reader

Writing code to read or write text files can be tricky because the exact contents of a file cannot be viewed in a text editor if the file contains non-printable characters such as line feeds or carriage returns. This simple … Continue reading

Posted in Uncategorized | 1 Comment

Complex Numbers

C99 introduced a new addition to the standard library to support complex numbers. The area of complex numbers is a vast one so in this post I will just give an overview of the C types and some of the … Continue reading
Posted in Uncategorized | Leave a comment

Finding the Highest Common Factor with the Euclidean Algorithm

The Euclidean Algorithm is a simple method for finding the highest common factor or HCF (also known as greatest common divisor or GCD) of two positive integers. This is an implementation of the algorithm in C.
Posted in Uncategorized | Leave a comment

Selection Sort

There are many sorting algorithms, often with variations and optimizations, and every now and again I will be coding some of them for this site. A while ago I wrote a post on bubble sort and here is a follow … Continue reading

Posted in Uncategorized | Leave a comment

Code2HTML – Formatting C Code as HTML

All the posts on this blog contain C source code which has been reformatted as HTML. This would be incredibly tedious to do by hand so I put together a quick and dirty utility to do it for me. It's … Continue reading
Posted in Uncategorized | Leave a comment

Using Valgrind to Detect Memory Management Problems

The C language has a reputation for being difficult to learn and to code in. I think this is unfair as it is actually a very small and simple language, but most of the perceived difficulty with using C comes … Continue reading
Posted in Uncategorized | Leave a comment