Pages

Friday, 9 February 2018

Create a structure to specify data of customers in a bank. The data to be stored is: Account number, Name, Balance in account. Assume maximum of 200 customers in the bank. (a) Write a function to print the Account number and name of each customer with balance below Rs. 100. (b) If a customer request for withdrawal or deposit, it is given in the form: Acct. no, amount, code (1 for deposit, 0 for withdrawal) Write a program to give a message, “The balance is insufficient for the specified withdrawal”.


Create a structure to specify data of customers in a bank. The data to be stored is: Account number, Name, Balance in account. Assume maximum of 200 customers in the bank.
(a) Write a function to print the Account number and name of each customer with balance below Rs. 100.
(b) If a customer request for withdrawal or deposit, it is given in the form:
Acct. no, amount, code (1 for deposit, 0 for withdrawal)
Write a program to give a message, “The balance is insufficient for the specified withdrawal”.

/* NOTE: since number of customers to be assumed is too much ( about 200 )

I have alloted full size (about 200) to it but array has been kept empty,

if you have time then you can fill up all 200 names and can search through

them.program has been tested by me and it works accurately. you can reduce
the size of array of structure conveniently by changing the value of N */

#include<stdio.h>
#include<conio.h>
#define N 200

struct bank {
     int acn;
     char name[20];
     int bal;         /* defined out of main() */
     };

void main() {

struct bank b[N];

int i,ch,lw=100,ch2,ac,am;

clrscr();

for(i=0;i<N;i++) {           /* inputting customer data */

printf("\tEnter information of customers \n");
printf("\t******************************\n\n");

printf("enter account no.: ");
scanf("%d",&b[i].acn);

printf("\n\nenter customer name: ");
scanf("%s",&b[i].name);

printf("\n\nenter balance: ");
scanf("%d",&b[i].bal);

clrscr();

}

clrscr();

printf("\tEnter your choice\n");    /* further processing of transaction */
printf("\t*****************\n\n");

printf("1: to know whose balance is below 100.\n\n");
printf("2: to process request or withdrawl.\n\n\n");


scanf("%d",&ch);

switch(ch) {

case 1:

      clrscr();

      disp(&b);         /* displaying whose balance is below 100 */

      break;



case 2:

     clrscr();

     printf("enter your account number: ");
     scanf("%d",&ac);

     for(i=0;i<N;i++) {

     if((b[i].acn)==ac) {

     clrscr();

     printf("\tHello %s\n",b[i].name);
     printf("\n\n");

     printf("\n\nenter your choice\n");
     printf("\n1: deposite:\n");
     printf("\n0: withdrawl:\n\n");
     scanf("%d",&ch2);

     switch(ch2) {


     case 0:

     clrscr();

    if(b[i].bal<lw) {

    printf("\n\nsorry! account balance is too low for withdrawl.\n");

    break;
    }

    else {

    printf("\n\nenter amount for withdrawl: ");
    scanf("%d",&am);

    }

    if(b[i].bal<am) {

    printf("\n\nyou don't have enough balance for withdrawl.\n");


    }


    else {

    b[i].bal=b[i].bal+am;

    printf("\n\nwithdrawl was successful.\n");

    }
    break;

     case 1:

   clrscr();

   printf("\n\nenter amount to deposite: ");
   scanf("%d",&am);

   b[i].bal=b[i].bal+am;

   printf("\n\ncash deposited successfully.\n\n");

   break;

}

}
}
}
 getch();
 }

disp(struct bank *a) {

int k;

printf("\tCustomers whose balance is below 100:\n");
printf("\t*************************************\n\n");

for(k=0;k<N;k++) {

if((a[k].bal)<100) {

printf("%2d\t%s\n",a[k].acn,a[k].name);

}
}
return 0;

 }