//ASSIGNMENT: write functions in three files using C : Create a make file to com
ID: 3836942 • Letter: #
Question
//ASSIGNMENT: write functions in three files using C :
Create a make file to compile and link all three files.
Do not change the names of the three files: deposit.c , withdraw.c and atm.c
I will use your makefile to compile my versions of the files.
1. Just create the makefile.
2. Your makefile should be able to compile individual files: deposit.c and withdraw.c
3. Your makefile should create a executable file : atm which I will execute and check. In other words, your makefile should have a target named atm will generate the executable
4. Your makefile should also have a target named clean that will erase all *.o files.
5. Make sure you don't delete *.c or *.txt files.
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1. deposit.c
void deposit ( float *bal, float amount )
{
*bal = *bal + amount;
}
2. withdraw.c
void withdraw ( float *bal, float amount )
{
*bal = *bal - amount;
}
3. atm.c
int main ( )
{
float balance = 200.00 ;
deposit ( &balance , 10 ) ;
printf ( " Balance %f " , balance ) ;
withdraw ( &balance, 20 ) ;
printf ( " Balance %f " , balance ) ;
}
Explanation / Answer
A simplest makefile can be
atm : atm.o deposit.o withdrawl.o
cc -o atm atm.o deposit.o withdrawl.o
atm.o : atm.c
cc -c main.c
deposit.o : deposit.c
cc -c deposit.c
withdrawl.o : withdrawl.c
cc -c withdrawl.c
clean :
rm atm atm.o deposit.o withdrawl.o
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.