Thursday, January 10, 2013

Bank App : Costumer Name, Account Number,Balance, Withdrew, Deposit etc. (C Program)


#include<stdio.h>
#include<conio.h>

struct bank
{
char name[20];
int an,bal;
};


void display();
void print_low();
int deposite();
int withdrow();

void main()
{
int i,j,k,n,m,blog=0,choise;
struct bank v[20];
clrscr();

printf("\n\tEnter Number : ");
scanf("%d",&n);

for(i=0;i<n;i++)
{
fflush(stdin);
printf("\n\n\tEnter Costomer Name : ");
gets(v[i].name);
fflush(stdin);
printf("\n\tEnter Account Number : ");
scanf("%d",&v[i].an);
fflush(stdin);
printf("\n\tEnter Account Balance : ");
scanf("%d",&v[i].bal);
}

printf("\n\n\tPress 1 for show Costomer Balance Less than 1000 ");
printf("\n\tPress 2 for Wihdriw or Deposite Balance ");
printf("\n\tPress 3 for All Details ");
scanf("%d",&choise);

switch(choise)
{
case 1:
{
for(i=0;i<n;i++)
{
print_low(v[i]);
}
break;
}
case 2:
{
printf("Enter Ammount ");
scanf("%d",m);
for(i=0;i<n;i++)
{
/*if(m==v[i].bal)
{*/
blog=1;
printf("Enter 1 for Withdrow Enter 2 for Deport :");
scanf("%d",&j);
if(j==1)
{
v[i].bal=deposite(v[i]);
}
else
{
v[i].bal=withdrow(v[i]);
}
/*}*/
}
break;
}
case 3:
{
for(i=0;i<n;i++)
{
display(v[i]);
}
break;
}
/*default
printf("Wrong Input ");*/
}

getch();
}

void display(struct bank c)
{
printf("\n\n\tName\tAcount\tBalance\n");
printf("\t%s\t%d\t%d",c.name,c.an,c.bal);
}

void print_low(struct bank c)
{
if (c.bal<1000)
{
printf("\n\n\tName\tAcount\tBalance\n");
printf("\t%s\t%d\t%d",c.name,c.an,c.bal);
}
}

int deposite(struct bank c)
{
int s;
printf("Enter Ammount Deposite ");
scanf("%d",&s);
c.bal=c.bal+s;
return(0);
}

int withdrow(struct bank c)
{
int s;
printf("Enter Ammount withdrow ");
scanf("%d",&s);

if(c.bal-s>0)
{
c.bal=c.bal-s;
return(c.bal);
}
else
{
printf("Not Enough cash to withdrow ! ");
}
return(0);

}

No comments:

Post a Comment