Untitled
unknown
plain_text
9 months ago
2.1 kB
9
Indexable
#include <stdio.h>
int main() {
int choice;
float balance = 1000, amount;
int pin, enteredPin;
int attempts = 0;
pin = 1111;
printf("===== Welcome to ATM =====\n");
while (attempts < 3) {
printf("Enter your PIN: ");
scanf("%d", &enteredPin);
if (enteredPin == pin) {
printf("PIN verified successfully!\n");
while (1) {
printf("\n===== ATM MENU =====\n");
printf("1. Check Balance\n");
printf("2. Deposit Money\n");
printf("3. Withdraw Money\n");
printf("4. Exit\n");
printf("Enter choice: ");
scanf("%d", &choice);
switch (choice) {
case 1:
printf("Your Balance = %.2f\n", balance);
break;
case 2:
printf("Enter amount to deposit: ");
scanf("%f", &amount);
balance += amount;
printf("Deposited! New Balance = %.2f\n", balance);
break;
case 3:
printf("Enter amount to withdraw: ");
scanf("%f", &amount);
if (amount > balance)
printf("Insufficient Balance!\n");
else {
balance -= amount;
printf("Withdrawn! New Balance = %.2f\n", balance);
}
break;
case 4:
printf("Thank you for using ATM!\n");
return 0;
default:
printf("Invalid choice!\n");
}
}
} else {
attempts++;
printf("Incorrect PIN! Attempts left: %d\n", 3 - attempts);
}
}
printf("Too many wrong attempts! Card blocked.\n");
return 0;
}Editor is loading...
Leave a Comment