Skip to content

Capstone · C Programming (from zero to systems)

Capstone: kirana stock and GST billing in C

Capstoneexpert· about 14 hours· 11 steps

The brief

Build a complete command-line billing system for a kirana shop in C: stock kept in a heap array and saved to a binary file, GST invoices worked out in paise with CGST and SGST, Indian digit grouping, a low-stock report sorted with qsort, unit tests, a Makefile, a clean valgrind and sanitizer run, and a git repository with a README you can show an employer.

Why it matters

Billing and inventory software runs every shop counter, from a neighbourhood kirana to a supermarket chain, and point-of-sale terminals and billing printers often run C. This capstone shows in one repository the things embedded and systems employers look for: clean multi-file structure, careful memory and file handling, exact money arithmetic, tests and tool-checked code. It makes a strong portfolio project for campus placements.

Skills you practise

  • multi-file C and headers
  • Makefiles with variables and pattern rules
  • structs and heap arrays
  • binary files with fwrite and fread
  • integer money and GST rounding
  • qsort with a comparator
  • unit tests
  • valgrind and sanitizers
  • git

You need

  • Linux or WSL with gcc, make, valgrind and git (sudo apt install build-essential valgrind git)
  • About 14 hours over one or two weeks

What you will have at the end

A git repository with a multi-file C kirana billing system (item.h, main.c, money.c, stock.c, bill.c, test_money.c, Makefile, README.md): GST invoices in paise with Indian digit grouping, a binary stock file, a qsort low-stock report, passing unit tests, and clean valgrind and sanitizer runs; plus kirana.js with the tested GST and formatting logic.

How it is marked (rubric, 100 points)
Correct resultsEvery check passes: the money tests, the stock list, the 248-byte file, the invoice to Rs 1,202.30, the updated stock and the low-stock order.30
Code quality and structureSmall functions in the right files, prototypes in item.h, no magic numbers, no warnings, every return value checked.25
Memory and file safetyrealloc through a temporary pointer, bounded strings, every malloc freed and every file closed, valgrind and sanitizers clean.20
Portfolio presentationA clear README with build steps, design notes and test results, a .gitignore, and sensible commits.15
Money done rightPaise in integers throughout, GST rounded per line, CGST and SGST that always add up, and Indian digit grouping.10

0/11 steps done

Step 1 of 11

GST maths in paise, tested in JavaScript

lineGst rounds GST to the nearest paisa, and invoiceTotals gives the subtotal, GST, CGST, SGST and total of a cart.

Money must be exact, and floating point is not: 0.1 + 0.2 is not 0.3 in a double. Shops and banks keep money as whole paise in integers. GST on a line is amount × rate / 100, rounded to the nearest paisa; with whole numbers, (amount × rate + 50) / 100 rounded down does exactly that, and C integer division rounds down for you.

GST is split equally into CGST (central) and SGST (state). If the total GST is an odd number of paise, give CGST the half rounded down and SGST the rest, so the two always add up. Get this right here; bill.c in step 7 uses the same formulas. The GST rates in this project are examples: real rates depend on the item and change (many changed in September 2025).

Run shows what your code prints. Check runs the step's tests. Ctrl+Enter checks too.