Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- const int MAXSIZE=100;
- float checking_balance(float a[],int x);
- float deposit(float a[], int x, int y);
- float withdraw(float a[], int x, int y);
- float transfer();
- int main()
- {
- float account[MAXSIZE];
- int n,e,f,g;
- printf("Enter number of customers:");
- scanf(" %d", &n);
- printf("Enter amount in each customer's account:");
- char c;
- for(int i=1;i<=n;i++)
- {
- scanf("%f", &account[i]);
- }
- printf("Select one of the following ATM operations\n");
- printf("Checking the balance amount (B)\n");
- printf("Withdrawing the amount from the account (W)\n");
- printf("Depositing the amount to the account (D)\n");
- printf("Transfer (T)\n");
- printf("Enter choice:\n");
- scanf(" %c", &c);
- switch(c)
- {
- case 'B':
- {
- printf("Enter debit account number:");
- scanf(" %d", &e);
- printf("Current balance in account #%d is %f", e,checking_balance(account,e));
- break;
- }
- case 'D':
- {
- printf("Enter credit account number:");
- scanf(" %d", &e);
- printf("Enter the amount to be deposited:");
- scanf(" %d", &f);
- printf("Current balance in account #%d is %f", e,deposit(account,e,f));
- break;
- }
- case 'W':
- {
- printf("Enter debit account number:");
- scanf(" %d", &e);
- printf("Enter the amount to be withdrawn:");
- scanf(" %d", &f);
- printf("Current balance in account #%d is %f", e,withdraw(account,e,f));
- break;
- }
- case 'T':
- {
- printf("Enter debit account number:");
- scanf(" %d", &e);
- printf("Enter credit account number:");
- scanf(" %d", &g);
- printf("Enter amount to deposit:");
- scanf(" %d", &f);
- transfer(account,e,g,f);
- break;
- }
- }
- return 0;
- }
- float checking_balance(float a[],int x)
- {
- return a[x];
- }
- float deposit(float a[], int x, int y)
- {
- a[x]=a[x]+y;
- return checking_balance(a,x);
- }
- float withdraw(float a[], int x, int y)
- {
- if((a[x]-y)>=0)
- {
- a[x]=a[x]-y;
- return checking_balance(a,x);
- }
- else
- {
- printf("Sorry the transaction isn't possible\n");
- return checking_balance(a,x);
- }
- }
- float transfer(float a[],int x, int y,int z)
- {
- if((a[x]-z)>=0)
- {
- printf("Current balance in account #%d is %f\n", x,withdraw(a,x,z));
- printf("Current balance in account #%d is %f\n", y,deposit(a,y,z));
- }
- else
- {
- printf("Sorry the transaction isn't possible\n");
- printf("Current balance in account #%d is %f\n", x,checking_balance(a,x));
- printf("Current balance in account #%d is %f\n", y,checking_balance(a,y));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment