C Programming Projects - Simple Calculator with History

Last Updated: 2025-08-15 17:38:10

simple calculator with history

If you are searching for C programming projects with source code that are perfect for practice, this one’s for you. In this project, we’ll build a simple calculator in a C program with the added ability to store calculation history in a file. This makes it an excellent choice for C programming projects for beginners, projects in the C programming language, and even C programming projects for students who want to learn file handling. We will share the complete source code so you can try it yourself and improve your C skills.

Β 

Project Details - Simple Calculator with History

This project with C programming goes beyond the basics by saving every calculation into a history file. It’s designed to teach beginners both arithmetic operations and file handling in projects on the C programming language.

Main Features:

  • Basic Operations – Supports +, -, *, and / using switch-case.
  • Save to File – Automatically stores results in history.txt as a + b = c.
  • View History – Display all past calculations anytime.
  • Clear History – Instantly remove all saved records.
  • Clear Console – Keep the interface clean with one command.
  • Run Until Exit – Perform multiple tasks until you choose E to exit.

You can download the complete source code and run it in Code::Blocks, Dev‑C++, or any C compiler.

Key Feature - Keeping the History

The standout feature of this simple calculator with history is its ability to keep past results saved in a file. This is a practical learning example for storing information in file using C.

  • Automatic Saving – Every calculation is stored without needing extra steps.
  • Readable Format – History entries are simple and easy to understand (5 + 3 = 8).
  • Persistent Storage – The file keeps your data even after you close the program.
  • Quick Access – View your entire calculation history anytime from the menu.
  • Full Control – Easily clear the history file when you want a fresh start.

Β 

void showMenu() {
    printf("\n\t===== Simple Calculator =====\n");
    printf("\t1. C - Calculate\n");
    printf("\t2. H - View History\n");
    printf("\t3. X - Clear History\n");
    printf("\t4. L - Clear Console\n");
    printf("\t5. E - Exit\n");
    printf("\t=============================\n");
    printf("\tEnter your choice: ");
}

// Save calculation to history
void saveToHistory(double a, char op, double b, double res) {
    FILE *file = fopen(HISTORY_FILE, "a");
    if (!file) {
        printf("Error saving history.\n");
        return;
    }
    fprintf(file, "%.2lf %c %.2lf = %.2lf\n", a, op, b, res);
    fclose(file);
}

You can download the complete source code to see exactly how this feature is implemented.

Β 

Similar type of projects.

You can practice by doing a similar type of project. Here is the list of similar types of projects with source code.

Β 

  1. Student Management System Project in C

Project Improvement Ideas

Here are some ways you can improve this C programming project idea:

  • Add timestamps to every calculation.
  • Include advanced math functions like modulus, power, and square root.
  • Implement a memory feature to reuse the last answer.
  • Allow searching in history for specific operators or numbers.
  • Add colored text output for a better user experience.

Β 

This is one of the best C programming projects for beginners who want to learn file handling, arithmetic operations, and menu-driven programming. Download the complete source code, run it, and start learning by doing.

Still you face problems, feel free to contact with me, I will try my best to help you.