STRUCTURE
STRUCTURE
Hey guys now the turn to get the knowledge regarding the structure in which I also include the switch case, not to make the program complex but to increase your capability to solve the complex program.
The program is based on the bank system.
You have choices, that are:
1.NEW ACCOUNT
2.SHOW BAL
3.DEPOSIT
4.EXIT
Hey guys now the turn to get the knowledge regarding the structure in which I also include the switch case, not to make the program complex but to increase your capability to solve the complex program.
The program is based on the bank system.
You have choices, that are:
1.NEW ACCOUNT
2.SHOW BAL
3.DEPOSIT
4.EXIT
The whole program proceed on behalf of the selection of your choice.
So try to understand the program and comments if you face any problem
or if you need the solution for any other program.

PROGRAM:-
#include<stdio.h>
#include<conio.h>
struct customer
{
int accno;
char name[25];
char type;
int deposit;
int bal;
};
void main()
{
struct customer c;
int ch,accno=1;
clrscr();
printf("\t\t MENU
\n 1.NEW ACCOUNT \n 2.SHOW BAL \n 3.DEPOSIT\n 4.EXIT");
printf("\n enter
ur choice");
scanf("%d",&ch);
switch(ch)
{
case 1:
printf("\n enter ur name");
fflush(stdin);
gets(c.name);
printf("\n enter the type of acc u want(c/s)");
scanf("%c",&c.type);
if(c.type=='c')
{
printf("\n please deposit 1000 rs to open ur acc \n and get
all the the service's
regarding your account type. ");
regarding your account type. ");
}
else
{
if(c.type=='s')
{
printf("\n please deposit 500 rs to open ur acc \n and get
all the the
service's regarding your account type. ");
service's regarding your account type. ");
}
}
printf("and get all the the service's regarding your
account type. ");
break;
case 2:
printf("\n
enter ur acc no");
scanf("%d",&c.accno);
printf("enter
type of ur accont(c/s):");
fflush(stdin);
scanf("%c",&c.type);
if(c.type=='c')
{
printf("\n ur balance is RS 1000\n");
}
else
{
if(c.type=='s')
{
printf("\n your balance is RS
500\n");
}}
break;
case 3:
c.bal=1000;
printf("\n
enter how much money u want to deposit");
scanf("%d",&c.deposit);
c.bal=c.bal+c.deposit;
printf("current
bal is %d",c.bal);
}
getch();
}
............................................
2 comments
fflush(stdin);
ReplyDeletewhat is the function of this line....
It's a function which allows you to flush [clear] the input buffer. You might use this function if you are thinking that there might be some data in input buffer which can create problems for you while taking user inputs from stdin.
ReplyDeleteor in simple world we can say this reduce the garbage collection related problems,....