Question
BANKING SYSTEM PROGRAM* Create a function in C LANGUAGE (not C++) which will assign a random account number of 6 digit, random name, random mobile
BANKING SYSTEM PROGRAM* Create a function in C LANGUAGE (not C++) which will assign a random account number of 6 digit, random name, random mobile number, random street and random city address, as well as random balance. Basically instead of asking the details of customer, the random function will create random details. But account ID is not random, the account ID will be in ascending order starting with 1 and going up to total number of customer. Because we search customer from his account ID. In simple words, when we run this random function for 100 customer, the first customer should have account ID 1 and last should have 100. So it is pretty ordered.
void print_all() { FILE *fp=fopen("customer_data.bin","rb"); printf("ID | ACCOUNT NO. | NAME | MOBILE NO. | STREET | CITY | BALANCE | ACTIVE? "); while( fread(&customer, sizeof(customer), 1, fp) == 1 ) { printf("%d | ", customer.number); printf("%d | ", customer.acct_no); printf("%s | ", customer.name); printf("%d | ", customer.mobile_no); printf("%s | ", customer.street); printf("%s | ", customer.city); printf("%.2f | ", customer.balance); check_account_status(customer.number); printf(" "); } fclose(fp); int m; do { printf(" ================================ "); printf("Press 1 to come back to main menu "); scanf("%d", &m); } while(m!=1); }
void input() { FILE *fp=fopen("customer_data.bin","rb"); int highest_id = 0; while( fread(&customer, sizeof(customer), 1, fp) == 1 ) { highest_id = customer.number; } fclose(fp); customer.number=highest_id+1; printf(" Customer ID:%d ", customer.number); printf(" Account number:"); scanf("%d",&customer.acct_no); printf(" Name:"); scanf("%s",customer.name); printf(" Mobile number:"); scanf("%d",&customer.mobile_no); printf(" Street:"); scanf("%s",customer.street); printf(" City:"); scanf("%s",customer.city); printf(" Balance:"); scanf("%f",&customer.balance); printf(" "); return; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started