0% found this document useful (0 votes)
1K views

Sample C Programming Code For Bank Application

The document provides a sample C programming code for a real-time bank application. The code allows users to perform operations like creating new accounts, depositing and withdrawing cash, displaying account information, and logging out. It uses structures to store account details and functions to implement each operation. The main program runs a loop that displays a menu and switches between operations based on user input.

Uploaded by

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

Sample C Programming Code For Bank Application

The document provides a sample C programming code for a real-time bank application. The code allows users to perform operations like creating new accounts, depositing and withdrawing cash, displaying account information, and logging out. It uses structures to store account details and functions to implement each operation. The main program runs a loop that displays a menu and switches between operations based on user input.

Uploaded by

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

Code for Bank Application

A sample C programming code for real time Bank application program is given below. This program will
perform all below operations.

1. Creating new account – To create a new account


2. Cash Deposit – To Deposit some amount in newly created account
3. Cash withdrawal – To Withdraw some amount from your account
4. Display Account information – It will display all informations of the existing accounts
5. Log out
6. Clearing the output screen and display available options
SAMPLE C PROGRAMMING CODE FOR BANK APPLICATION:
1 #include <stdio.h>
2 #include <conio.h>
3 #include <string.h>
4 #include <stdlib.h>
5
6 // Structure declaration
7 struct acc_type
8 {
9 char bank_name[20];
10 char bank_branch[20];
11 char acc_holder_name[30];
12 int acc_number;
13 char acc_holder_address[100];
14 float available_balance;
15 };
16 struct acc_type account[20];
17
18 /*
19 printf("The above structure can be declared using
20 typedef like below");
21
22 typedef struct acc_type
23 {
24 char bank_name[20];
25 char bank_branch[20];
26 char acc_holder_name[30];
27 int acc_number;
28 char acc_holder_address[100];
29 float available_balance;
30 }Acc_detail;
31
32 Acc_detail account[20];
33 */
34
35 int num_acc;
36
37 void Create_new_account();
38 void Cash_Deposit();
39 void Cash_withdrawl();
40 void Account_information();
41 void Log_out();
42 void display_options();
43
44 /* main program */
45 int main()
46 {
47 char option;
48 char f2f[50] = "http://fresh2refresh.com/";
49 num_acc=0;
50 while(1)
51 {
52 printf("\n***** Welcome to Bank Application *****\n");
53 printf("\nThis demo program is brought you by %s",f2f);
54 display_options();
55 printf("Please enter any options (1/2/3/4/5/6) ");
56 printf("to continue : ");
57
58 option = getch();
59 printf("%c \n", option);
60 switch(option)
61 {
62 case '1': Create_new_account();
63 break;
64 case '2': Cash_Deposit();
65 break;
66 case '3': Cash_withdrawl();
67 break;
68 case '4': Account_information();
69 break;
70 case '5': return 0;
71 case '6': system("cls");
72 break;
73 default : system("cls");
74 printf("Please enter one of the options");
75 printf("(1/2/3/4/5/6) to continue \n ");
76 break;
77 }
78 }
79 return 0;
80 }
81
82 /*Function to display available options in this application*/
83
84 void display_options()
85 {
86 printf("\n1. Create new account \n");
87 printf("2. Cash Deposit \n");
88 printf("3. Cash withdrawl \n");
89 printf("4. Account information \n");
90 printf("5. Log out \n");
91 printf("6. Clear the screen and display available ");
92 printf("options \n\n");
93 }
94
95 /* Function to create new account */
96
97 void Create_new_account()
98 {
99 char bank_name[20];
100 char bank_branch[20];
101 char acc_holder_name[30];
102 int acc_number;
103 char acc_holder_address[100];
104 float available_balance = 0;
105 fflush(stdin);
106 printf("\nEnter the bank name : ");
107 scanf("%s", &bank_name);
108 printf("\nEnter the bank branch : ");
109 scanf("%s", &bank_branch);
110 printf("\nEnter the account holder name : ");
111 scanf("%s", &acc_holder_name);
112 printf("\nEnter the account number(1 to 10): ");
113 scanf("%d", &acc_number);
114 printf("\nEnter the account holder address : ");
115 scanf("%s", &acc_holder_address);
116
117 strcpy(account[acc_number-1].bank_name,bank_name);
118 strcpy(account[acc_number-1].bank_branch,bank_branch);
119 strcpy(account[acc_number-1].acc_holder_name,
120 acc_holder_name);
121 account[acc_number-1].acc_number=acc_number;
122 strcpy(account[acc_number-1].acc_holder_address,
123 acc_holder_address);
124 account[acc_number-1].available_balance=available_balance;
125
126 printf("\nAccount has been created successfully \n\n");
127 printf("Bank name : %s \n" ,
128 account[acc_number-1].bank_name);
129 printf("Bank branch : %s \n" ,
130 account[acc_number-1].bank_branch);
131 printf("Account holder name : %s \n" ,
132 account[acc_number-1].acc_holder_name);
133 printf("Account number : %d \n" ,
134 account[acc_number-1].acc_number);
135 printf("Account holder address : %s \n" ,
136 account[acc_number-1].acc_holder_address);
137 printf("Available balance : %f \n" ,
138 account[acc_number-1].available_balance);
139
140 //num_acc++;
141
142 }
143
144 // Displaying account informations
145
146 void Account_information()
147 {
148 register int num_acc = 0;
149 //if (!strcmp(customer,account[count].name))
150 while(strlen(account[num_acc].bank_name)>0)
151 {
152 printf("\nBank name : %s \n" ,
153 account[num_acc].bank_name);
154 printf("Bank branch : %s \n" ,
155 account[num_acc].bank_branch);
156 printf("Account holder name : %s \n" ,
157 account[num_acc].acc_holder_name);
158 printf("Account number : %d \n" ,
159 account[num_acc].acc_number);
160 printf("Account holder address : %s \n" ,
161 account[num_acc].acc_holder_address);
162 printf("Available balance : %f \n\n" ,
163 account[num_acc].available_balance);
164 num_acc++;
165 }
166 }
167
168 // Function to deposit amount in an account
169
170 void Cash_Deposit()
171 {
172 auto int acc_no;
173 float add_money;
174
175 printf("Enter account number you want to deposit money:");
176 scanf("%d",&acc_no);
177 printf("\nThe current balance for account %d is %f \n",
178 acc_no, account[acc_no-1].available_balance);
179 printf("\nEnter money you want to deposit : ");
180 scanf("%f",&add_money);
181
182 while (acc_no=account[acc_no-1].acc_number)
183 {
184 account[acc_no-1].available_balance=
185 account[acc_no-1].available_balance+add_money;
186 printf("\nThe New balance for account %d is %f \n",
187 acc_no, account[acc_no-1].available_balance);
188 break;
189 }acc_no++;
190 }
191
192 // Function to withdraw amount from an account
193
194 void Cash_withdrawl()
195 {
196 auto int acc_no;
197 float withdraw_money;
198
199 printf("Enter account number you want to withdraw money:");
200 scanf("%d",&acc_no);
201 printf("\nThe current balance for account %d is %f \n",
202 acc_no, account[acc_no-1].available_balance);
203 printf("\nEnter money you want to withdraw from account ");
204 scanf("%f",&withdraw_money);
205
206 while (acc_no=account[acc_no-1].acc_number)
207 {
208 account[acc_no-1].available_balance=
209 account[acc_no-1].available_balance-withdraw_money;
210 printf("\nThe New balance for account %d is %f \n",
211 acc_no, account[acc_no-1].available_balance);
212 break;
213 }acc_no++;
214 }
SAMPLE BANK APPLICATION OUTPUT USING C PROGRAMMING CODE:

You might also like