Ad Code

Responsive Advertisement

Simple Banking System using C language

 Simple Banking System using C language



Code :

#include <stdio.h>

#include <conio.h>

#include <stdlib.h>

#include <string.h>


int displayMenu();

void deposit();

void withdraw();

void transfer();

void checkDetails();

void finalView();


// Global Variable

int totalAmount = 1000,

    depositAmount, withdrawAmount, transferAmount,

    totalDeposit = 0, totalWithdraw = 0, totalTransfer = 0, 

    accountNo;

    char name[30];


// Start Execution of the program

int main()

{

    printf("Enter your Name : ");

    gets(name);


    printf("Enter your Account : ");

    scanf("%d", &accountNo);


    while (1)

    {

        switch (displayMenu())

        {

        case 1:

            deposit();

            totalDeposit += depositAmount;

            break;

        case 2:

            withdraw();

            if (withdrawAmount <= totalAmount)

            {

                totalWithdraw += withdrawAmount;

            }

            break;

        case 3:

            transfer();

            if (transferAmount <= totalAmount)

            {

                totalTransfer += transferAmount;

            }

            break;

        case 4:

            checkDetails();

            break;

        case 5:

            finalView();

            exit(0);

            break;


        default:

            printf(" Invalid NO !!\n");

        }

    }


    getch();

    return 0;

}


// Function Definations 


int displayMenu()

{

    int ch;

    printf("1. Deposit Amount : \n");

    printf("2. Withdraw Amount : \n");

    printf("3. Transfer Amount : \n");

    printf("4. Check Details Amount : \n");

    printf("5. Exit : \n");

    printf("Enter your choice : \n");

    scanf("%d", &ch);


    return (ch);

}


void deposit()

{

    printf("How much amount to deposit in your account \n");

    scanf("%d", &depositAmount);

    totalAmount += depositAmount;

}


void withdraw()

{

    printf("How much amount to Withdraw in your account \n");

    scanf("%d", &withdrawAmount);

    if (withdrawAmount <= totalAmount)

    {

        totalAmount -= withdrawAmount;

    }

    else

    {

        printf("Your Bank Balance is less than %d please check it.  Your Available Bank balance is %d.", withdrawAmount, totalAmount);

    }

}


void transfer()

{

    printf("How much amount to Transfer. \n");

    scanf("%d", &transferAmount);

    if (transferAmount <= totalAmount)

    {

        totalAmount -= transferAmount;

    }

    else

    {

        printf("Your Bank Balance is less than %d please check it.  Your Available Bank balance is %d.", transferAmount, totalAmount);

    }

}


void checkDetails()

{

    printf("Total amount is : %d\n", totalAmount);

    printf("Total Deposit amount is : %d\n", totalDeposit);

    printf("Total Withdraw amount is : %d\n", totalWithdraw);

    printf("Total Transfer amount is : %d\n", totalTransfer);

    printf("\n");

}


void finalView()

{

    printf("Account Holder : %s \n", name);

    printf("Account Number is : %d \n", accountNo);

    printf("Total amount is : %d\n", totalAmount);

    printf("Total Deposit amount is : %d\n", totalDeposit);

    printf("Total Withdraw amount is : %d\n", totalWithdraw);

    printf("Total Transfer amount is : %d\n", totalTransfer);

    printf("\n");

}

Post a Comment

0 Comments

Ad Code

Responsive Advertisement