#include <stdio.h>
#include <time.h>

int main() {
    int pin = 1234, enteredPin = 1234, count = 0, option, amount = 1;
    float balance = 5000;
    int continueTransaction = 1;

    time_t now;

    time(&now);
    printf("\n");
    printf("\t\t\t\t\t       %s", ctime(&now));
    printf("\n\t\t\t==============Welcome To Convenient ATM==============");

    // Assuming a known pin for testing purposes
    // enteredPin = 1234;

    while (pin != enteredPin) {
        // No need to prompt for pin entry in this case
        if (enteredPin != pin) {
            printf("Invalid pin! ");
        }

        count++;

        if (count == 3 && pin != enteredPin) {
            return 0; // Exit the program after three unsuccessful attempts
        }
    }

    while (continueTransaction != 0) {
        printf("\n\t\t\t=============Available Transactions==============");
        printf("\n\n\t\t1. Withdrawal");
        printf("\n\n\t\t2. Deposit");
        printf("\n\n\t\t3. Check Balance");
        printf("\n\n\t\tPlease select the option: ");
        scanf("%d", &option);

        switch (option) {
            case 1:
                while (amount % 20 != 0) {
                    printf("\n\n\t\tEnter the amount: ");
                    scanf("%d", &amount);
                    if (amount % 20 != 0)
                        printf("\n\n\t\tAmount should be multiples of 20! ");
                }

                if (balance < amount) {
                    printf("\n\n\t\tSorry, insufficient funds! ");
                    amount = 1;
                } else {
                    balance -= amount;
                    printf("\n\n\t\tYou have withdrawn Rs.%d. Your new balance is %.2f", amount, balance);
                    printf("\n\n\t\t==============Thank You for banking with Convenience ATM! =================");
                    amount = 1;
                }
                break;

            case 2:
                printf("\n\n\t\tPlease enter the amount: ");
                scanf("%d", &amount);
                balance += amount;
                printf("\n\n\t\tYou have deposited Rs.%d. Your new balance is %.2f", amount, balance);
                printf("\n\n\t\t==============Thank You for banking with Convenience ATM! =================");
                amount = 1;
                break;

            case 3:
                printf("\n\n\t\tYour balance is Rs.%.2f", balance);
                break;

            default:
                printf("\n\n\t\tInvalid Option!");
        }

        printf("\n\n\t\tDo you want to perform another transaction? Press 1 [Yes], 0 [No]: ");
        scanf("%d", &continueTransaction);
    }

    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: