Thursday, November 22, 2012

C PROGRAM FOR BANK OPERATION USING FUNCTIONS


/* C PROGRAM FOR  BANK OPERATION USING FUNCTIONS*/


#include<stdio.h>
#include<conio.h>
int amt=10000,b,w,d,n;
void deposit()
{
     printf("Enter amount\n");
     scanf("%d",&d);
     amt=amt+d;
     printf("Your amount is:%d\n",amt);
 }

void withdraw()
{
     printf("Enter amount\n");
     scanf("%d",&w);
     if(amt>=100)
     {
      amt=amt-w;
      printf("Your amt is:%d\n",amt);
     }
     else
     printf("You have below 100 Rs\n");
}

void balance()
{
      printf("The balance amount is :%d\n",amt);
 }
















void main()
{
      int ba;
      clrscr();
      printf("\t\t BANKING OPERATION USING FUNCTION \n\n");
      printf("1.Deposit\n2.Withdraw\n3.Balance\n4.Exit\n");
     do
    {

       printf("\n Enter any choice:");
        scanf("%d",&ba);
        switch(ba)
        {
          case 1:
                    deposit();
                    break;
          case 2:
                    withdraw();
                     break;
          case 3:
                    balance();
                    break;
          case 4:
                        getch();
                        break;
       }
    }while(ba!=4);
     getch();
}
















OUTPUT:


                 BANKING OPERATION USING FUNCTION


1. Deposit
2. Withdraw
3. Balance
4. Exit

 Enter any choice: 1
Enter amount:
1200
Your amount is: 11200

 Enter any choice: 2
Enter amount:
11200
Your amt is: 0

 Enter any choice: 2
Enter amount:
1000
You have below 100 rs

 Enter any choice: 1
Enter amount:
15000
Your amount is: 15000

 Enter any choice: 3
The balance amount is: 15000

 Enter any choice: 4





0 comments:

Post a Comment