C Programs | IT Developer
IT Developer

C Programs



Share with a Friend

Mini Banking System with Simple Interest and Compound Interest Program in C

Introduction (Banking Application in C)

A Banking System is a great real-world project to practice C programming.
It simulates basic banking operations like:

  • Account creation (basic details)
  • Deposit & Withdraw money
  • Balance inquiry
  • Interest calculations (SI & CI options)
  • Exit option

This project demonstrates decision making, loops, functions, and menu-driven programs.

 

C Program: Mini Banking System with Simple Interest and Compound Interest Program

C

#include <stdio.h>

#include <math.h>

#include <string.h>

 

// Global account structure

struct Account {

    char name[50];

    int accountNumber;

    float balance;

} user;

 

// Function prototypes

void createAccount();

void deposit();

void withdraw();

void checkBalance();

void calculateInterest();

float simpleInterest(float p, float r, float t);

float compoundInterest(float p, float r, float t);

 

int main() {

    int choice;

 

    printf("===== Welcome to Simple Bank System =====\n");

    createAccount();

 

    do {

        printf("\n===== Banking Menu =====\n");

        printf("1. Deposit Money\n");

        printf("2. Withdraw Money\n");

        printf("3. Check Balance\n");

        printf("4. Calculate Interest (SI / CI)\n");

        printf("0. Exit\n");

        printf("Enter your choice: ");

        scanf("%d", &choice);

 

        switch(choice) {

            case 1: deposit(); break;

            case 2: withdraw(); break;

            case 3: checkBalance(); break;

            case 4: calculateInterest(); break;

            case 0: printf("\nThank you for using Simple Bank System!\n"); break;

            default: printf("\nInvalid choice! Please try again.\n");

        }

    } while(choice != 0);

 

    return 0;

}

 

// Create account function

void createAccount() {

    printf("\nEnter Account Holder Name: ");

    scanf(" %[^\n]s", user.name);

    printf("Enter Account Number: ");

    scanf("%d", &user.accountNumber);

    user.balance = 0.0;

    printf("\nAccount Created Successfully!\n");

}

 

// Deposit function

void deposit() {

    float amount;

    printf("\nEnter amount to deposit: ");

    scanf("%f", &amount);

    if(amount > 0) {

        user.balance += amount;

        printf("Amount %.2f deposited successfully!\n", amount);

    } else {

        printf("Invalid deposit amount!\n");

    }

}

 

// Withdraw function

void withdraw() {

    float amount;

    printf("\nEnter amount to withdraw: ");

    scanf("%f", &amount);

    if(amount > 0 && amount <= user.balance) {

        user.balance -= amount;

        printf("Amount %.2f withdrawn successfully!\n", amount);

    } else {

        printf("Invalid withdrawal amount or insufficient balance!\n");

    }

}

 

// Check balance function

void checkBalance() {

    printf("\nAccount Holder: %s\n", user.name);

    printf("Account Number: %d\n", user.accountNumber);

    printf("Current Balance: %.2f\n", user.balance);

}

 

// Calculate interest function

void calculateInterest() {

    float rate, time, si, ci;

    int choice;

 

    printf("\nEnter Rate of Interest (in %%): ");

    scanf("%f", &rate);

    printf("Enter Time (in years): ");

    scanf("%f", &time);

 

    printf("\n1. Simple Interest\n2. Compound Interest\nEnter your choice: ");

    scanf("%d", &choice);

 

    if(choice == 1) {

        si = simpleInterest(user.balance, rate, time);

        printf("\nSimple Interest on current balance = %.2f\n", si);

    } else if(choice == 2) {

        ci = compoundInterest(user.balance, rate, time);

        printf("\nCompound Interest on current balance = %.2f\n", ci);

    } else {

        printf("Invalid choice!\n");

    }

}

 

// Function to calculate SI

float simpleInterest(float p, float r, float t) {

    return (p * r * t) / 100;

}

 

// Function to calculate CI

float compoundInterest(float p, float r, float t) {

    float amount = p * pow((1 + r / 100), t);

    return amount - p;

}

Output

 
OUTPUT :
===== Welcome to Simple Bank System =====
Enter Account Holder Name: Anand Rao
Enter Account Number: 12345

Account Created Successfully!

===== Banking Menu =====
1. Deposit Money
2. Withdraw Money
3. Check Balance
4. Calculate Interest (SI / CI)
0. Exit
Enter your choice: 1

Enter amount to deposit: 5000
Amount 5000.00 deposited successfully!

===== Banking Menu =====
Enter your choice: 3

Account Holder: Anand Rao
Account Number: 12345
Current Balance: 5000.00

===== Banking Menu =====
Enter your choice: 4
Enter Rate of Interest (in %): 10
Enter Time (in years): 2

1. Simple Interest
2. Compound Interest
Enter your choice: 2

Compound Interest on current balance = 1050.00

Explanation

  1. Account Creation → User enters name & account number, initial balance = 0.
  2. Deposit/Withdraw → Updates balance with validation.
  3. Check Balance → Displays account details and balance.
  4. Interest Calculation → User enters rate & time, then selects SI or CI.
  5. Program runs until user chooses Exit.