Atm

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

27.

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

Enter your choice:3


The balance amount is 8000.

You might also like