mini C projects, billing system in C, calculator in C, console projects in C, C programming examples, beginner C projects, Tamil Technicians C course, menu driven programs in C, file handling billing system, C project for students,

Mini C Projects – Simple Billing System & Calculator in C (Console Projects)

Mini C Projects – Simple Billing System & Calculator in C (Console Projects) | Tamil Technicians

Tamil Technicians – C Programming Course · Mini Projects & Practice

Mini C Projects – Simple Billing System & Calculator in C (Console Projects)

After learning C basics – variables, operators, control statements, arrays, strings, functions, file handling – the next big step is to build mini projects. Mini projects convert theory into practical skills.

In this detailed lesson, we will design and build two classic console projects in C:

  • A Simple Billing System (for shop / service / electronics technician).
  • A Console Calculator (menu-driven, with error handling).

Both projects are text-based (run in the terminal), but they use many core concepts of C: arrays, struct, loops, conditionals, functions, and file handling. These are perfect for diploma / ITI / B.E. students and technicians who want to practice real C programs.

1. Why Mini C Projects Are Important

Reading syntax and small examples is useful, but real learning happens when you build something slightly bigger – where you have to:

  • Design data structures (e.g., arrays or structs for items and bills).
  • Break the problem into functions.
  • Handle user input carefully (validation, invalid choices, etc.).
  • Format output in a user-friendly way (bills, menus).
  • Think about maintainability and future features (saving to files, adding tax, etc.).
Goal

After this lesson, you should be able to:

  • Write a simple billing system for your own shop or service center (as a basic console app).
  • Create a calculator program that can be easily extended with more functions.
  • Use these mini projects as a base for bigger C / embedded / desktop projects.

2. Project 1 – Simple Billing System (Console)

Let’s start with a Simple Billing System that runs in the terminal. Think of a small electronics service center or parts shop. For each customer, you want to:

  • Enter multiple items (name, quantity, price).
  • Calculate total for each item (qty * price).
  • Compute subtotal, optional discount, tax, and final net total.
  • Display a clean bill on the screen.
Input

Customer & Items

Customer name, number of items, each item’s name, quantity and price.

Processing

Totals

Calculate line item totals, subtotal, discount, tax and net total.

Output

Bill

Nicely formatted bill printed in the console, optionally saved to a text file.

Concepts used

C Concepts

Arrays, structs, loops, functions, basic file handling and formatting.

3. Design the Billing System – Data Structures & Flow

Before jumping into code, let’s design the data we need.

3.1 Item structure

Each item in the bill has:

  • Name (string).
  • Quantity (integer).
  • Unit price (float).
  • Total amount for that item (float).
typedef struct {
    char  name[40];
    int   qty;
    float price;
    float total;
} Item;

3.2 Bill-level data

At the bill level, we need:

  • Customer name.
  • Array of items (maximum number, e.g., 50).
  • Number of items actually used.
  • Subtotal, discount, tax, net total.
#define MAX_ITEMS 50

typedef struct {
    char  customerName[50];
    Item  items[MAX_ITEMS];
    int   itemCount;
    float subTotal;
    float discount;
    float tax;
    float netTotal;
} Bill;

We could also add a bill number, date, etc., but for a first mini project this is enough.

3.3 Flow of the program

  1. Display a simple welcome heading.
  2. Ask for customer name.
  3. Ask how many items to enter (N).
  4. For each item i (from 1 to N), read name, quantity, price, compute total.
  5. Compute subtotal (sum of item totals).
  6. Optionally ask for discount percentage; compute discount amount.
  7. Compute tax and net total.
  8. Print formatted bill.

4. Full Code – Basic Billing System (Console Only)

Below is a complete C program for a single-bill simple billing system. It reads data from the user and prints the bill on the console.

#include <stdio.h>
#include <string.h>

#define MAX_ITEMS 50

typedef struct {
    char  name[40];
    int   qty;
    float price;
    float total;
} Item;

typedef struct {
    char  customerName[50];
    Item  items[MAX_ITEMS];
    int   itemCount;
    float subTotal;
    float discount;  // amount
    float tax;       // amount
    float netTotal;
} Bill;

int main() {
    Bill bill;
    int i;
    float discountPercent = 0.0f;
    float taxPercent = 0.0f;

    printf("===== SIMPLE BILLING SYSTEM (C CONSOLE) =====\\n\\n");

    // Read customer name
    printf("Enter customer name: ");
    // Use space before % to skip previous newline
    scanf(" %49[^\n]", bill.customerName);

    // Read number of items
    printf("Enter number of items (max %d): ", MAX_ITEMS);
    scanf("%d", &bill.itemCount);

    if (bill.itemCount <= 0 || bill.itemCount > MAX_ITEMS) {
        printf("Invalid number of items. Exiting.\\n");
        return 1;
    }

    // Read each item
    bill.subTotal = 0.0f;

    for (i = 0; i < bill.itemCount; i++) {
        printf("\\nItem %d name: ", i + 1);
        scanf(" %39[^\n]", bill.items[i].name);

        printf("Quantity: ");
        scanf("%d", &bill.items[i].qty);

        printf("Unit price: ");
        scanf("%f", &bill.items[i].price);

        bill.items[i].total = bill.items[i].qty * bill.items[i].price;
        bill.subTotal += bill.items[i].total;
    }

    // Ask for discount and tax
    printf("\\nEnter discount (in %%): ");
    scanf("%f", &discountPercent);

    printf("Enter tax (in %%): ");
    scanf("%f", &taxPercent);

    bill.discount = bill.subTotal * (discountPercent / 100.0f);
    bill.tax = (bill.subTotal - bill.discount) * (taxPercent / 100.0f);
    bill.netTotal = bill.subTotal - bill.discount + bill.tax;

    // Print the bill
    printf("\\n==============================================\\n");
    printf("                 VERBISOFT SHOP                \\n");
    printf("==============================================\\n");
    printf("Customer: %s\\n", bill.customerName);
    printf("----------------------------------------------\\n");
    printf("%-3s %-20s %5s %10s %10s\\n",
           "No", "Item", "Qty", "Price", "Total");
    printf("----------------------------------------------\\n");

    for (i = 0; i < bill.itemCount; i++) {
        printf("%-3d %-20s %5d %10.2f %10.2f\\n",
               i + 1,
               bill.items[i].name,
               bill.items[i].qty,
               bill.items[i].price,
               bill.items[i].total);
    }

    printf("----------------------------------------------\\n");
    printf("%-30s %10s %10.2f\\n", "", "Subtotal:", bill.subTotal);
    printf("%-30s %10s %10.2f\\n", "", "Discount:", bill.discount);
    printf("%-30s %10s %10.2f\\n", "", "Tax:", bill.tax);
    printf("%-30s %10s %10.2f\\n", "", "NET TOTAL:", bill.netTotal);
    printf("==============================================\\n");
    printf("          THANK YOU! VISIT AGAIN              \\n");
    printf("==============================================\\n");

    return 0;
}
You can customize the shop name, tax rate and discount logic to match your real use. For example, fixed GST rate, or auto discount when subtotal exceeds a limit.

5. Saving the Bill to a Text File (Extension)

For a slightly more advanced mini project, we can save each bill into a text file (like bill.txt), using the file handling functions you learned earlier (fopen, fprintf, fclose).

5.1 Simple function to save bill

We can add a function that receives a Bill and writes it to a file:

void saveBillToFile(const Bill *bill, const char *filename) {
    int i;
    FILE *fp = fopen(filename, "a");   // append mode

    if (fp == NULL) {
        printf("Error opening %s for writing.\\n", filename);
        return;
    }

    fprintf(fp, "==============================================\\n");
    fprintf(fp, "Customer: %s\\n", bill->customerName);
    fprintf(fp, "%-3s %-20s %5s %10s %10s\\n",
            "No", "Item", "Qty", "Price", "Total");

    for (i = 0; i < bill->itemCount; i++) {
        fprintf(fp, "%-3d %-20s %5d %10.2f %10.2f\\n",
                i + 1,
                bill->items[i].name,
                bill->items[i].qty,
                bill->items[i].price,
                bill->items[i].total);
    }

    fprintf(fp, "Subtotal: %.2f, Discount: %.2f, Tax: %.2f, Net: %.2f\\n",
            bill->subTotal, bill->discount, bill->tax, bill->netTotal);
    fprintf(fp, "==============================================\\n\\n");

    fclose(fp);
}

In main(), after printing the bill to the screen, call:

saveBillToFile(&bill, "bills.txt");
Now every time you run the billing system, a copy of the bill is appended to bills.txt. Later, you can import that file into a spreadsheet or write another C program to analyze monthly totals.

6. Adding a Simple Menu – New Bill / Exit

To make the billing system feel like a real console app, we can add a loop with a small menu:

int main() {
    int choice;

    do {
        printf("\\n===== BILLING SYSTEM MENU =====\\n");
        printf("1. Create new bill\\n");
        printf("2. Exit\\n");
        printf("Enter your choice: ");
        scanf("%d", &choice);

        if (choice == 1) {
            // call function that handles billing logic
            createBill();
        } else if (choice != 2) {
            printf("Invalid choice, please try again.\\n");
        }
    } while (choice != 2);

    printf("Exiting...\\n");
    return 0;
}

Here, createBill() would contain the code we wrote earlier for reading customer name, items, calculating totals and printing/saving the bill. Separating it into a function keeps main() clean.

7. Project 2 – Console Calculator in C

The second mini project is a Console Calculator. On the surface this seems simple, but you can gradually extend it to practice many C features:

  • Basic operations: addition, subtraction, multiplication, division.
  • Modulus (remainder), power, square root (using math.h).
  • Menu-driven interface, loops and switch–case.
  • Error checking (division by zero, invalid menu choice).
UI

Menu Driven

User chooses which operation to perform, then enters numbers.

Concepts

Switch & Loops

Core practice for switch, while and do-while constructs.

Error handling

Safe Division

Check denominator before division to avoid runtime errors.

Extensions

Scientific

Add advanced operations later as you learn more C and math functions.

8. Full Code – Menu Driven Calculator

Let’s implement a calculator that runs in a loop until the user chooses to exit. It supports +, -, *, /, and % (modulus for integers).

#include <stdio.h>

int main() {
    int choice;
    double a, b, result;
    int x, y, r;

    do {
        printf("\\n===== SIMPLE CALCULATOR (C CONSOLE) =====\\n");
        printf("1. Addition (a + b)\\n");
        printf("2. Subtraction (a - b)\\n");
        printf("3. Multiplication (a * b)\\n");
        printf("4. Division (a / b)\\n");
        printf("5. Modulus (x %% y)\\n");
        printf("0. Exit\\n");
        printf("Enter your choice: ");
        scanf("%d", &choice);

        switch (choice) {
            case 1:
                printf("Enter two numbers: ");
                scanf("%lf %lf", &a, &b);
                result = a + b;
                printf("Result = %.2lf\\n", result);
                break;

            case 2:
                printf("Enter two numbers: ");
                scanf("%lf %lf", &a, &b);
                result = a - b;
                printf("Result = %.2lf\\n", result);
                break;

            case 3:
                printf("Enter two numbers: ");
                scanf("%lf %lf", &a, &b);
                result = a * b;
                printf("Result = %.2lf\\n", result);
                break;

            case 4:
                printf("Enter two numbers: ");
                scanf("%lf %lf", &a, &b);
                if (b == 0) {
                    printf("Error: division by zero is not allowed.\\n");
                } else {
                    result = a / b;
                    printf("Result = %.2lf\\n", result);
                }
                break;

            case 5:
                printf("Enter two integers: ");
                scanf("%d %d", &x, &y);
                if (y == 0) {
                    printf("Error: modulus by zero is not allowed.\\n");
                } else {
                    r = x % y;
                    printf("Result = %d\\n", r);
                }
                break;

            case 0:
                printf("Exiting calculator...\\n");
                break;

            default:
                printf("Invalid choice. Please try again.\\n");
        }
    } while (choice != 0);

    return 0;
}
This calculator includes basic safety checks for division and modulus. You can improve formatting, add input validation, or wrap operations into functions (e.g., add(), subtract()).

9. Extending the Calculator – Functions & New Operations

Once the basic menu-driven calculator is working, you can refactor it to use functions for each operation. This keeps main() clean and matches good programming style.

9.1 Using functions for operations

double add(double a, double b) {
    return a + b;
}

double subtract(double a, double b) {
    return a - b;
}

double multiply(double a, double b) {
    return a * b;
}

double divide(double a, double b) {
    return a / b;
}

Then in main():

case 1:
    printf("Enter two numbers: ");
    scanf("%lf %lf", &a, &b);
    printf("Result = %.2lf\\n", add(a, b));
    break;

Similarly for other operations. This approach makes it easy to test each function separately and reuse them in other projects.

9.2 Adding more features

  • Power: use pow(a, b) from <math.h>.
  • Square root: use sqrt(a) from <math.h>.
  • Trigonometric functions: sin, cos, tan, etc.
  • History log: save calculations to a file (similar to bills).
  • Input repeat: ask user if they want to calculate again with same numbers.

10. Connecting Both Projects – Common Concepts

Even though the billing system and calculator are different use cases, they share many concepts:

Concept Billing System Calculator
Menu New bill / exit options. Operation selection (add, sub, etc.).
Loops Repeated bills in one session. Repeated calculations until user exits.
Input validation Item count, prices >= 0. Non-zero denominator, valid choice.
Formatting Bill layout with columns. Neat display of results.
File handling (extension) Saving bills to text files. Saving calculation history (optional).

Practicing both mini projects will make your understanding of loops, conditionals, functions and input/output much stronger.

11. Testing & Debugging Your Mini Projects

Mini projects are also a great way to practice testing and debugging. Here are some tips:

11.1 Test with different inputs

  • Billing system:
    • 0 items (should be rejected as invalid).
    • 1 item vs many items.
    • Very high quantities / prices (check for overflow or formatting issues).
    • Discount = 0, tax = 0; discount 50%, tax 18%, etc.
  • Calculator:
    • Positive and negative numbers.
    • Division by zero (should show an error, not crash).
    • Modulus with negative numbers (behaviour depends on implementation).
    • Invalid menu choices (e.g., 9, -1, 100).

11.2 Use printf for debugging

If calculations seem wrong, add temporary printf statements to inspect intermediate values:

printf("DEBUG: subTotal = %.2f, discount = %.2f, tax = %.2f\\n",
       bill.subTotal, bill.discount, bill.tax);

Once you confirm the logic is correct, you can remove or comment out those debug lines.

11.3 Keep code clean and readable

  • Use meaningful variable names (subTotal, netTotal, choice).
  • Break long functions into smaller helper functions.
  • Add comments for non-obvious parts.
  • Use consistent indentation and spacing.

12. Practice Ideas – Make the Projects Your Own

Once you understand the base versions, try modifying and extending them:

12.1 Billing system extensions

  • Add a bill number and date.
  • Provide a menu option to view previous bills from file.
  • Support multiple payment methods (cash, UPI, card) with a note at the bottom.
  • Implement category-wise items (electronics, spare parts, labour charges).
  • Store bills in a CSV format that can be opened in Excel.

12.2 Calculator extensions

  • Add memory functions (M+, M-, MR, MC).
  • Implement a scientific mode with sin, cos, tan, log.
  • Support unit conversions (e.g., Celsius–Fahrenheit, kW–HP).
  • Allow chained calculations (use the previous result as the next input).
  • Log calculations to a file, with timestamps.
These extensions are excellent mini project ideas for internal assessments, lab exams and portfolio building. Start small, then keep improving.

13. Learning Checklist – Mini C Projects

  • I can design data structures (structs and arrays) for a practical problem.
  • I understand how to implement a menu-driven program with loops and switch.
  • I can build a basic billing system that calculates totals and prints a formatted bill.
  • I know how to extend the billing system to save bills to a text file.
  • I can implement a console calculator that handles multiple operations safely.
  • I can refactor code into functions to make it cleaner and easier to maintain.
  • I understand how to test my mini projects with different inputs and edge cases.
  • I have ideas for extending these mini projects into more advanced applications.

FAQ: Mini C Projects – Billing System & Calculator

1. Are these mini projects suitable for first-year students?

Yes. As long as you know basic C syntax (variables, operators, loops, if, switch), you can build these projects. They are perfect as first or second semester mini projects.

2. Do I need advanced topics like pointers to complete these projects?

For the basic versions, you don’t need deep pointer knowledge. Simple arrays and structures are enough. Pointers become more important when you start writing reusable libraries or dynamic memory versions.

3. Can I use these projects as a base for a GUI application later?

Absolutely. The core logic (calculations, bill totals, menu handling) can later be reused in a GUI application (e.g., using C with a graphics library or switching to another language with the same logic).

4. How can I show these mini projects in my resume or portfolio?

Keep your code in a version control system like Git, document features in a README file, include sample screenshots (console output), and mention the technologies used (C, file handling, structs). This gives recruiters a clear picture of your practical C skills.

Category: C Programming Course · Lesson – Mini C Projects (Simple Billing System & Calculator)


Buy link ;

Lenovo V14 Intel Core i5 13th Gen 14″ FHD (1920×1080) Antiglare 250 Nits Thin and Light Laptop (16GB RAM/512GB SSD/Windows 11 Home/Office 2024/Iron Grey/1.43 kg), 83A0A0PTIN.


Contact link ;

Click Here >>>>>>


Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top