ATM program in c
The C programming language is used for creating the ATM Program, making it simple to comprehend and read the instructions. The foundation of this ATM usage programme is the idea of treating each account separately.
It can be described as an easy to use, basic coding structure for the ATM transaction process. We might need to employ a function for carrying out this job, but in the interim, cause statements might be changed for ease of code.
Since it is not time-consuming, we may also use the mini-program from this ATM programming in C to check the account's overall balance, make a deposit, and take money out of the balance.
Properties of ATM:
The three types of coding syntax used in ATM transactions are performed by the C programme:
1. Checking account balances
2. Taking money from an ATM
3. Deposit of money
The following steps are part of the process semantic structure:
- In the beginning, we must alter or configure the ATM pin, the amount, and a few number generators.
- Consider the ATM card as the point of input.
- We can then carry out further actions if the specified input pin satisfies the altered pin exactly.
- We'll use the switch statement to carry out operations like checking the balance, taking out money, putting money back in, and other similar ones.
- A while loop can be used to continue or end the process as well.
How ATM program in C:
The three logical steps that the ATM programme follows for an appropriate transaction are cash withdrawal, deposit, and balance check. The switch between cases in C with initialised variables as well as functions with conditions are used to run these three programme segments. Only when all the requirements are met do the results come true precisely.
For instance, while using ATM programme C, only proceed with the withdrawal process if the amount of money in your banking account is sufficient; otherwise, choose another choice or perform another transaction. In addition, the ATM programme will display the most recent balance in the account when the code component is executed after a user deposits money into the account. When using the final approach, the user can examine the amount of his or her account before making any ATM transactions or deposits.
The following strategic steps are carried out by this ATM programme written in C to operate the ATM Machine:
- The ATM Transaction can be displayed using this C programme code.
- It contains the pin verification system for login into the ATM machine.
- The account balance can also be checked using this ATM programme.
- Even cash withdrawals are made simpler by this ATM programme in C.
- This ATM programme can also be used to deposit cash.
- When a single withdrawal is complete, an ATM machine engages a switch case that permits numerous transactions. The user can decide to exit, in which circumstance the application will end, if a single transaction is still exceptional.
Example:
#include <stdio.h>
// starting account balance
float accountBal = 1000.0;
// Function to display the main menu
void displayMainMenu() {
printf("\n welcome to ATM Menu:\n");
printf("1. Check the Balance\n");
printf("2. Deposit cash\n");
printf("3. Withdraw cash\n");
printf("4. Exit\n");
printf("Enter your choice: ");
}
// Function to check account balance
void checkAccBalance() {
printf("Your current balance is: $%.2f\n", accBalance);
}
// Function to deposit money
void depositCash() {
float cash;
printf("Enter the money to deposit: ");
scanf("%f", &cash);
if (cash > 0) {
accBalance += cash;
printf("Deposit successful! Your new remaining balance is: $%.2f\n", accBalance);
} else {
printf("Invalid money for deposit.\n");
}
}
// Function to withdraw money
void withdraw() {
float cash;
printf("Enter the cash to withdraw: ");
scanf("%f", &cash);
if (cash > 0 && cash <= accBalance) {
accBalance -= cash;
printf("Withdrawal successful! Your new balance is: $%.2f\n", accBalance);
} else {
printf("Invalid cash for withdrawal or insufficient balance.\n");
}
}
int main() {
int choice;
do {
displayMainMenu();
scanf("%d", &choice);
switch (choice) {
case 1:
checkAccBalance();
break;
case 2:
depositCash();
break;
case 3:
withdraw();
break;
case 4:
printf("Thank you for using the ATM.\n");
break;
default:
printf("Invalid choice. Please select a valid option.\n");
}
} while (choice != 4);
return 0;
}
Output:
![ATM program in c](https://static.tutorialandexample.com/c/atm-program-in-c1.png)
Conclusion:
C programming is ideal for beginner programmers, thus learning some basic C programming concepts is necessary before moving on.
The four main principles of every ATM system currently in use, including cash withdrawal, cash withdrawal, balances on accounts examinations, and functionality for additional transactions or termination, must be included while writing an ATM machine programme in C.