Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In a file named account.c implement all of the functions declared in the account.h file. It's important that you understand everything in account.h , so
In a file named account.c implement all of the functions declared in the account.h file. It's important that you understand everything in account.h so if there is anything in it that you don't understand, look it up Make sure that your account.c file works with the following file mainc and produces the output shown below.
All amounts and balances should be positive. Amounts for withdrawals should not be greater than the account balance, and amounts for transfers should not be greater than the balance of the source account. If any of these constraints are violated then the transaction should not be executed and the function should return a negative integer as its return value.
The only function that should print anything is accountprint.
Use a command line like this to compile your program:
gcc o main mainc account.c
That command line tells the compiler to compile mainc and account.c and to make an executable file named main
account.h
#include
#define MAXNAMELEN
typedef struct
int id;
int balance;
char ownerMAXNAMELEN; USED FOR A STRING
Account;
int accountinitAccount acctp int id int balance, char owner;
int accountdepositAccount acctp int amount;
int accountwithdrawAccount acctp int amount;
int accounttransferAccount fromp Account top int amount;
int accountprintAccount acctp;
Link to download file: account.hDownload account.h
mainc
#include
#include "account.h
int mainint argc, char argv
Account a a;
accountinit&a "Hermione Granger";
accountinit&a "Jack Swallow";
accountdeposit&a;
accountwithdraw&a;
accountwithdraw&a;
accounttransfer&a &a;
accountprint&a;
accountprint&a;
Link to download file: maincDownload mainc
Output
In the output below, the dollar sign represents the shell prompt and the name of the executable file is main
$ main
Hermione Granger $
Jack Swallow $
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