The Notorious Bubble Sort

I am sticking my neck out here by implementing the notorious Bubble Sort in C. There are many sorting algorithms and even more variations on a theme, but the bubble sort is probably the best known. It’s simple to understand and the process can be illustrated with some cute animations and even Hungarian folk dancing!

Continue reading

Posted in Uncategorized | 5 Comments

Calculating Any Term of the Fibonacci Sequence Using Binet’s Formula

You can calculate the Fibonacci Sequence by starting with 0 and 1 and adding the previous two numbers, but Binet’s Formula can be used to calculate directly any term of the sequence. This short project is an implementation of the formula in C.

Continue reading

Posted in Uncategorized | Leave a comment

Logarithms: a Practical Use

This is a simple little C project demonstrating a useful application of logarithms, with the bonus of a few lines demonstrating localization.

Continue reading

Posted in Uncategorized | 2 Comments

Zeller’s Congruence – Calculating the Day of the Week

Today I’ll write an implementation in C of Zeller’s Congruence, a simple and elegant little formula to carry out the seemingly complex task of calculating the day of the week (Monday, Tuesday etc.) from a date.

Continue reading

Posted in Uncategorized | Leave a comment

Writing an SVG Library

In this post I will develop a simple C library to create and save an SVG (Scalable Vector Graphics) file, complete with a few examples of its use.

Continue reading
Posted in Uncategorized | 1 Comment

Welcome to Code in C

Welcome to Code in C. This site will present useful, informative and interesting bits of C code, and give visitors the opportunity to comment, improve and expand on them.

Continue reading

Posted in Uncategorized | Leave a comment