0% found this document useful (0 votes)
8 views4 pages

cpro.c

Uploaded by

adarsh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views4 pages

cpro.c

Uploaded by

adarsh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

#include<stdio.

h>
#include<conio.h>
#include<process.h>
void main()
{
int amt,acno,m,i,ch,bal,acn,cnt;
char nm[10],ad[20],phno[15],pan[22],pin[10];
FILE*fp;
FILE*fp1;
FILE*fp2;

clrscr();
abcd:
printf("\n==============================BANK
MANAGEMENT==================================");
printf("\n\n\n\n\n***** BANK MANAGEMENT****\n");
printf("*********");
printf("\n\t\t\t1. Create New Account");
printf("\n\t\t\t2. Update Information of Existing Account");
printf("\n\t\t\t3. Amount to pay");
printf("\n\t\t\t4. Amount to recive");
printf("\n\t\t\t5. Check The Details Of Existing Account");
printf("\n\t\t\t6. Removing Existing Account");
printf("\n\t\t\t7. View Customer's List");
printf("\n\t\t\t8. Exit");
printf("\n***********");
printf("\n\n\n\nEnter your choice......");
scanf("%d",&ch);

switch(ch)
{
case 1:
//Create New Account//
fp=fopen("bank.dat","w");

for(i=0;i<5;i++)
{
printf("Enter account number");
scanf("%d",&acno);
printf("enter name");
scanf("%s",&nm);
printf("Enter phone number");
scanf("%s",&phno);
printf("Enter address");
scanf("%s",&ad);
printf("Enter pin code");
scanf("%s",&pin);
printf("Enter pan number");
scanf("%s",&pan);
printf("Enter account balance");
scanf("%d",&bal);
fprintf(fp,"\n%d\t%s\t%s\t%s\t%s\t%s\t%d",acno,nm,phno,ad,pin,pan,bal);
}
fclose(fp);
goto abcd;
case 2:
//update information (Edit) of new Account
fp=fopen("bank.dat","r");
fp1=fopen("temp.dat","w");
printf("Enter account number :");
scanf("%d",&acn);
for(i=0;i<5;i++)
{
fscanf(fp,"\n%d\t%s\t%s\t%s\t%s\t%s\t%d\
n",&acno,&nm,&phno,&ad,&pin,&pan,&bal);
if(acno==acn)
{
printf("\n%d\t%s\t%s\t%s\t%s\t%s\t%d\n",acno,nm,phno,ad,pin,pan,bal);

printf("Enter new account number");


scanf("%d",&acno);
printf("enter new name");
scanf("%s",&nm);
printf("Enter new phone number");
scanf("%s",&phno);
printf("Enter new address");
scanf("%s",&ad);
printf("Enter new pin code");
scanf("%s",&pin);
printf("Enter new pan number");
scanf("%s",&pan);
printf("Enter new account balance");
scanf("%d",&bal);
fprintf(fp1,"\n%d\t%s\t%s\t%s\t%s\t%s\t%d",acno,nm,phno,ad,pin,pan,bal);
}
else
{
fprintf(fp1,"\n%d\t%s\t%s\t%s\t%s\t%s\t%d",acno,nm,phno,ad,pin,pan,bal);
}
}
fclose(fp);
fclose(fp1);
fp=fopen("temp.dat","r");
fp1=fopen("bank.dat","w");
for(i=0;i<5;i++)
{
fscanf(fp,"\n%d\t%s\t%s\t%s\t%s\t%s\t%d\n",&acno,&nm,&phno,&ad,&pin,&pan,&bal);
fprintf(fp1,"\n%d\t%s\t%s\t%s\t%s\t%s\t%d",acno,nm,phno,ad,pin,pan,bal);
}
fclose(fp);
fclose(fp1);

goto abcd;

case 3:
fp=fopen("bank.dat","r");
printf("Enter account number");
scanf("%d",&acn);
for(i=0;i<5;i++)
{
fscanf(fp,"\n%d\t%s\t%s\t%s\t%s\t%s\t%d",&acno,&nm,&phno,&ad,&pin,&pan,&bal);
amt=0;

if(acno==acn)
{
printf("\n%d\t%s\t%s\t%s\t%s\t%s\t%d",acno,nm,phno,ad,pin,pan,bal);
printf("\n ACCOUNT HAVE BEEN DEBITED");
printf("\n\nAmount to pay :");
scanf("%d",&amt);
bal=bal+amt;
printf("\n\n your account have been deposited\n");
printf("\n Current Account Balance %d",bal);
}
}

fclose(fp);
goto abcd;

case 4:
fp=fopen("bank.dat","r");
printf("Enter account number");
scanf("%d",&acn);
for(i=0;i<5;i++)
{
fscanf(fp,"\n%d\t%s\t%s\t%s\t%s\t%s\t%d",&acno,&nm,&phno,&ad,&pin,&pan,&bal);
if(acno==acn)
{
printf("\n%d\t%s\t%s\t%s\t%s\t%s\t%d",acno,nm,phno,ad,pin,pan,bal);
printf("\nEnter amount");
scanf("%d",&amt);
if(bal<amt)
{
printf("NOT HAVING SUFFICIENT AMOUNT");
}
else
{
bal=bal-amt;
printf("\n\n your account have been debited\n");
printf("\n Current Account Balance %d",bal);
}
}
}
fclose(fp);
goto abcd;
case 5:
fp=fopen("bank.dat","r");
printf("Enter Account No. to Search :");
scanf("%d",&acn);

for(i=0;i<5;i++)
{
fscanf(fp,"%d\t%s\t%s\t%s\t%s\t%s\t%d",&acno,&nm,&phno,&ad,&pin,&pan,&bal);
if(acno==acn)
{
printf("\n%d\t%s\t%s\t%s\t%s\t%s\t%d",acno,nm,phno,ad,pin,pan,bal);
}
}
fclose(fp);
printf("\n\n\nEnd of File Found.....");

goto abcd;
case 6:

fp=fopen("bank.dat","r");
fp1=fopen("temp.dat","w");
printf("Enter account number :");
scanf("%d",&acn);

for(i=0;i<5;i++)
{
fscanf(fp,"\n%d\t%s\t%s\t%s\t%s\t%s\t%d\
n",&acno,&nm,&phno,&ad,&pin,&pan,&bal);
if(acno==acn)
{
printf("\n%d\t%s\t%s\t%s\t%s\t%s\t%d\n",acno,nm,phno,ad,pin,pan,bal);
cnt--;
}
else
{
fprintf(fp1,"\n%d\t%s\t%s\t%s\t%s\t%s\t%d",acno,nm,phno,ad,pin,pan,bal);
}
}
fclose(fp);
fclose(fp1);
fp=fopen("temp.dat","r");
fp1=fopen("bank.dat","w");
for(i=0;i<cnt;i++)
{
fscanf(fp,"\n%d\t%s\t%s\t%s\t%s\t%s\t%d\n",&acno,&nm,&phno,&ad,&pin,&pan,&bal);
fprintf(fp1,"\n%d\t%s\t%s\t%s\t%s\t%s\t%d",acno,nm,phno,ad,pin,pan,bal);
}
fclose(fp);
fclose(fp1);
break;
case 7:
fp=fopen("bank.dat","r");

for(i=0;i<5;i++)
{
fscanf(fp,"%d\t%s\t%s\t%s\t%s\t%s\t%d",&acno,&nm,&phno,&ad,&pin,&pan,&bal);
if(acno!=m)
{

printf("\n%d\t%s\t%s\t%s\t%s\t%s\t%d",acno,nm,phno,ad,pin,pan,bal);
}
else
{
//goto here;
}
m=acno;
}
fclose(fp);
printf("\n\n\nEnd of File Found.....");

goto abcd;
case 8:
printf("EXITING");
exit(0);

}
getch();
}

You might also like