A sample C programming code for real time Bank application program is given below. This program will perform all below operations.
- Creating new account – To create a new account
- Cash Deposit – To Deposit some amount in newly created account
- Cash withdrawal – To Withdraw some amount from your account
- Display Account information – It will display all informations of the existing accounts
- Log out
- Clearing the output screen and display available options
Sample C programming Code for Bank Application:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 |
#include <stdio.h> #include <conio.h> #include <string.h> #include <stdlib.h> // Structure declaration struct acc_type { char bank_name[20]; char bank_branch[20]; char acc_holder_name[30]; int acc_number; char acc_holder_address[100]; float available_balance; }; struct acc_type account[20]; /* printf("The above structure can be declared using typedef like below"); typedef struct acc_type { char bank_name[20]; char bank_branch[20]; char acc_holder_name[30]; int acc_number; char acc_holder_address[100]; float available_balance; }Acc_detail; Acc_detail account[20]; */ int num_acc; void Create_new_account(); void Cash_Deposit(); void Cash_withdrawl(); void Account_information(); void Log_out(); void display_options(); /* main program */ int main() { char option; char f2f[50] = "https://www.fresh2refresh.com/"; num_acc=0; while(1) { printf("\n***** Welcome to Bank Application *****\n"); printf("\nThis demo program is brought you by %s",f2f); display_options(); printf("Please enter any options (1/2/3/4/5/6) "); printf("to continue : "); option = getch(); printf("%c \n", option); switch(option) { case '1': Create_new_account(); break; case '2': Cash_Deposit(); break; case '3': Cash_withdrawl(); break; case '4': Account_information(); break; case '5': return 0; case '6': system("cls"); break; default : system("cls"); printf("Please enter one of the options"); printf("(1/2/3/4/5/6) to continue \n "); break; } } return 0; } /*Function to display available options in this application*/ void display_options() { printf("\n1. Create new account \n"); printf("2. Cash Deposit \n"); printf("3. Cash withdrawl \n"); printf("4. Account information \n"); printf("5. Log out \n"); printf("6. Clear the screen and display available "); printf("options \n\n"); } /* Function to create new account */ void Create_new_account() { char bank_name[20]; char bank_branch[20]; char acc_holder_name[30]; int acc_number; char acc_holder_address[100]; float available_balance = 0; fflush(stdin); printf("\nEnter the bank name : "); scanf("%s", &bank_name); printf("\nEnter the bank branch : "); scanf("%s", &bank_branch); printf("\nEnter the account holder name : "); scanf("%s", &acc_holder_name); printf("\nEnter the account number(1 to 10): "); scanf("%d", &acc_number); printf("\nEnter the account holder address : "); scanf("%s", &acc_holder_address); strcpy(account[acc_number-1].bank_name,bank_name); strcpy(account[acc_number-1].bank_branch,bank_branch); strcpy(account[acc_number-1].acc_holder_name, acc_holder_name); account[acc_number-1].acc_number=acc_number; strcpy(account[acc_number-1].acc_holder_address, acc_holder_address); account[acc_number-1].available_balance=available_balance; printf("\nAccount has been created successfully \n\n"); printf("Bank name : %s \n" , account[acc_number-1].bank_name); printf("Bank branch : %s \n" , account[acc_number-1].bank_branch); printf("Account holder name : %s \n" , account[acc_number-1].acc_holder_name); printf("Account number : %d \n" , account[acc_number-1].acc_number); printf("Account holder address : %s \n" , account[acc_number-1].acc_holder_address); printf("Available balance : %f \n" , account[acc_number-1].available_balance); //num_acc++; } // Displaying account informations void Account_information() { register int num_acc = 0; //if (!strcmp(customer,account[count].name)) while(strlen(account[num_acc].bank_name)>0) { printf("\nBank name : %s \n" , account[num_acc].bank_name); printf("Bank branch : %s \n" , account[num_acc].bank_branch); printf("Account holder name : %s \n" , account[num_acc].acc_holder_name); printf("Account number : %d \n" , account[num_acc].acc_number); printf("Account holder address : %s \n" , account[num_acc].acc_holder_address); printf("Available balance : %f \n\n" , account[num_acc].available_balance); num_acc++; } } // Function to deposit amount in an account void Cash_Deposit() { auto int acc_no; float add_money; printf("Enter account number you want to deposit money:"); scanf("%d",&acc_no); printf("\nThe current balance for account %d is %f \n", acc_no, account[acc_no-1].available_balance); printf("\nEnter money you want to deposit : "); scanf("%f",&add_money); while (acc_no=account[acc_no-1].acc_number) { account[acc_no-1].available_balance= account[acc_no-1].available_balance+add_money; printf("\nThe New balance for account %d is %f \n", acc_no, account[acc_no-1].available_balance); break; }acc_no++; } // Function to withdraw amount from an account void Cash_withdrawl() { auto int acc_no; float withdraw_money; printf("Enter account number you want to withdraw money:"); scanf("%d",&acc_no); printf("\nThe current balance for account %d is %f \n", acc_no, account[acc_no-1].available_balance); printf("\nEnter money you want to withdraw from account "); scanf("%f",&withdraw_money); while (acc_no=account[acc_no-1].acc_number) { account[acc_no-1].available_balance= account[acc_no-1].available_balance-withdraw_money; printf("\nThe New balance for account %d is %f \n", acc_no, account[acc_no-1].available_balance); break; }acc_no++; } |
Sample bank application output using C programming code:
Continue on “C code for calculator application”….
Continue on “C interview questions and answers”….
OTHER C PROGRAMS:
- C program for prime number
- C program for factorial
- C program for fibonacci series
- C program for palindrome
- C program for swapping 2 numbers with and without temp variables
- C program to find leap year
- C program to find armstrong number
- C program to find simple and compound interest
- C program to find largest of given 3 numbers
- C program to find smallest of given 3 numbers
- C program to convert lower case into upper case and vice versa
- C program to find sum and average of given 3 numbers
- C program to sum up all individual digits
- C program to reverse given number
- C program to reverse given string
- C program to find strong number
- C program to find square and cube of given number
- C program to print hello world without using semi colon
- C program to sort given names in alphabetical order
- C program to copy content of one file to another
- C program to sort given numbers in ascending order
- C program to sort given numbers in descending order
- C program to search given number in an array
- C program for recursive function
- C program for calculator application
- C program for bank application
- C program to check given number is perfect number or not
- C program to find array size
- C program to find whether given character vowel or not
- C program to check whether given number is positive or negative
- C program to find sum of n numbers
- C program to compare 2 numbers without if statement
- C program to generate random numbers
- C program to compare 2 arrays whether they are equal or not
- C program to print number from 1 to 500 without using any loop conditions
- C program to insert an element into an array
- C program to delete an element from an array
- C program to find hcf (gcd) and lcm
- C program to print diamond pattern
- C program to print pascal triangle
- C program to add two complex numbers
- C program for matrix addition
- C program for matrix multiplication
- C program for bubble sort
- C program for insertion sort
- C program for selection sort