Google Ads

Wednesday, May 27, 2009

Bank Operations

BANK OPERATION - Using Functions

#include”stdio.h”
#include “conio.h”
void deposit();
void balance();
void withdraw();
int n;
float bal=0,wit,dep;
char nam[50];
void main()
{
int ch;
clrscr();
printf("\nEnter the Name of the Customer : ");
scanf("%s",nam);
printf("\nEnter the Account Number : ");
scanf("%d",&n);
do
{
printf("\n\n1.Deposit\n2.Balance\n3.Withdraw\n4.Exit\n");
printf("\nEnter the Operation to perform : ");
scanf("%d",&ch);
switch(ch)
{
case 1:
deposit();
break;
case 2:
balance();
break;
case 3:
withdraw();
break;
case 4:
exit(0);
break;
}
}while(ch<4);
getch();
}
void deposit()
{ printf("\nEnter the Amount to be Deposited : Rs.");
scanf("%f",&dep);
bal=bal+dep;
balance();
}
void balance()
{ printf("\n Account Number : %d",n);
printf("\n Name : %s",nam);
printf("\n Balance : Rs.%.2f",bal);
}
void withdraw()
{ printf("\nEnter the Amount to be withdrawn : Rs.");
scanf("%f",&wit);
if(wit>bal)
printf("\nWithdraw is not sucess");
else
bal=bal-wit;
balance();
}

No comments:

Post a Comment