This C program uses a case statement to create a simple ATM menu allowing the user to choose between depositing, withdrawing, or checking their balance. The user's selection determines which code block is executed to either update the balance variable or print the current amount. The balance is initialized to 8000 and transactions are performed by adding or subtracting amounts entered by the user. The updated or current balance is printed in each case.
This C program uses a case statement to create a simple ATM menu allowing the user to choose between depositing, withdrawing, or checking their balance. The user's selection determines which code block is executed to either update the balance variable or print the current amount. The balance is initialized to 8000 and transactions are performed by adding or subtracting amounts entered by the user. The updated or current balance is printed in each case.
This C program uses a case statement to create a simple ATM menu allowing the user to choose between depositing, withdrawing, or checking their balance. The user's selection determines which code block is executed to either update the balance variable or print the current amount. The balance is initialized to 8000 and transactions are performed by adding or subtracting amounts entered by the user. The updated or current balance is printed in each case.
This C program uses a case statement to create a simple ATM menu allowing the user to choose between depositing, withdrawing, or checking their balance. The user's selection determines which code block is executed to either update the balance variable or print the current amount. The balance is initialized to 8000 and transactions are performed by adding or subtracting amounts entered by the user. The updated or current balance is printed in each case.
Program to execute a menu of ATM using case statement
#include<stdio.h> int main() { char a; int dep,with,bal=8000,upbal; printf("1.Deposit \n2.Withdrawl \n3.Balance"); printf("\nEnter your choice:"); scanf("%c",&a); switch(a) { case '1': printf("Enter the amount to be deposited."); scanf("%d",&dep); upbal=bal+dep; printf("Current Balance %d",upbal); break; case '2': printf("Enter the amount to be withdrawn."); scanf("%d",&with); upbal=bal-with; printf("Current Balance %d",upbal); break; case '3': printf("The balance amount is 8000."); break; default: printf("Invalid choice");
} return 0; } Output: 1.Deposit 2.Withdrawl 3.Balance Enter your choice:1 Enter the amount to be deposited.850 Current Balance 8850
Enter your choice:2
Enter the amount to be withdrawn.450 Current Balance 7550