Projects in C

Projects in C

I created these nine projects as part of CS50x, which is the free online version of Harvard University’s Introduction to Computer Science. This course was nothing short of spectacular and it was very much the reason for my recent love for Computer Science and the C programming language. Here is a link to my edX/Harvard certificate.

Project 0: Scratch

Scratch Screenshot

To make our introduction to Computer Science as gentle as possible we made our first project in Scratch—a programming language developed by MIT for teaching programming to children, which uses a colourful block structure instead of actual code and which looks more like pseudocode (see “code” snippet above). The official objectives for this first project were:

  • Understand how information can be represented digitally.
  • Leverage some fundamental programming constructs.
  • Design your own animation, game, or interactive art.
  • Impress your friends.

You can play my simple memory game here.

Project 1: C

The first “real” programming assignment for this course was made up of two smaller programs with the following official objectives:

  • Get comfortable with Linux.
  • Start thinking more carefully.
  • Solve some problems in C.
Itsa Mario
For Itsa Mario we had to write a program in C that recreates Mario’s half-pyramid* using hashes instead of blocks. This involved doing some user input validation as well.

Time for Change
For Time for Change we had to create a greedy algorithm, i.e. to write a program in C that first asks the user how much change is owed and then spits out the minimum number of coins with which that change can be made.

* Toward the end of World 1-1 in Nintendo’s Super Mario Brothers, Mario must ascend a “half-pyramid” of blocks before leaping toward a flag pole.

Project 2: Crypto

For our second C project we had to write two programs that encrypt messages first using Caesar’s cipher and then Vigenère’s cipher*. The official objectives for this project were as follows:

  • Become better acquainted with functions and libraries.
  • Dabble in cryptography.

* Caesar’s cipher encrypts (i.e. scrambles in a reversible way) messages by “rotating” each letter by k positions, wrapping around from ‘Z’ to ‘A’ as needed. Vigenère’s cipher improves upon Caesar’s by encrypting messages using a sequence of keys (or, put another way, a keyword).

Project 3: Scramble

Our official objectives for this project were:

  • Learn to read and build upon someone else’s code.
  • Learn how to encapsulate data.
  • (Play.)

More specifically we had to implement the game Scramble, which challenges the player to find as many words as possible in a 4×4 grid of letters before a timer expires. Each pair of letters in a word can be adjacent horizontally, vertically, or diagonally.

Project 4: Forensics

Project 4 was my favourite as it was so much fun. The official objectives were:

  • Acquaint yourself with file I/O.
  • Get more comfortable with data structures, hexadecimal, and pointers.
  • Help Mr. Boddy.


For this project we had to imagine that we were guests in Tudor Mansion, where our host Mr. John Boddy was the victim of foul play and had met an untimely end. The only evidence left at the crime scene was a 24-bit BMP file, pictured above, that Mr. Boddy whipped up on his computer in his final moments. Hidden among this file’s red “noise” was a picture of the culprit. Our aim was to write a program that would determine whodunit.

And the verdict:
verdict black


For Resize we had to implement a program in C that resizes 24-bit uncompressed BMP files by a factor of n.


For Recover we had to write a program in C that recovers a number of “accidentally” deleted photos from a digital camera’s CompactFlash card.

Project 5: Misspellings

For this project we had to create the fastest spell-checker we could while using a staff-provided 143,091-word dictionary. The official objectives were as follows:

  • Design and implement your own data structure.
  • Optimize your code’s (real-world) running time.

Project 6: Huff’n Puff

For our final C project we had to implement a program that “puffs” (i.e., decompresses) files that have been huffed (i.e. Huffman-compressed) by the staff. The official objectives were:

  • Build and traverse binary trees.
  • Compress and decompress actual files

Project 7: C$50 Finance

For this project we had to implement C$50 Finance, a Web-based tool with which one can manage portfolios of stocks. This tool would allow you to check real stocks’ actual prices and portfolios’ values, as well as “buy” and “sell” stocks! Official objectives were:

  • Introduce yourself to HTML, CSS, PHP, and SQL.
  • Learn how to teach yourself new languages.

Final Project: Anti-Frost Watch

This project deserves its own post!