Makefile
to build
C source code into a program.
Makefile
for new
source files and targets.
R6
for the recitation,
all files should reside in this subdirectory. Copy the following
files to the R6
directory:
make
command, and note which commands are executed
when the program is built. Edit the Makefile
to see
the executable name and run the program from the command line.
Student
in the header
file to add a last name, average homework score, average lab
score, a midterm score, and a final exam score. All scores are
integers in the range 0…100, and all names are character
pointers (C strings).
struct.c
:
void inputScores(Student *student); void outputScores(Student student);The inputScores function should query standard input (with prompting) for the names and all scores. The outputScores function should print the names and scores (with labels) to standard output. Declare a global array of 5 students in
main.c
, and add a loop to the main entry point to
input and output 5 student records.
make
command,
and iterate until the program builds and you can input and
output student records. Hint: you can press ctrl-C so that you
don’t have to enter more than a couple student records.
totalPoints
(float
) and
finalGrade
(char
) fields to the
structure in struct.h
. Rebuild the program using
the Makefile
and notice which files are recompiled
and linked.
void calculateScores(Student *student);The
calculateScores
function will compute
totalPoints
and letterGrade
according to the formula:
totalPoints = homework average*0.30 + lab average*0.20 + midterm score*0.20 + final score*0.30; if (totalPoints > 90.0) letterGrade = 'A'; else if (totalPoints > 80.0) letterGrade = 'B'; else if (totalPoints > 70.0) letterGrade = 'C'; else if (totalPoints > 60.0) letterGrade = 'D'; else letterGrade = 'F';You will also need to add print statements for
totalPoints
and letterGrade
to the
outputScores
function.
make
command, and
note which files are recompiled and linked. Test the program
until it works, using the make
command to rebuild.
Touch main.c
and rebuild the program using
make
, and note which files are recompiled and
linked. This is the purpose of a Makefile
, to
figure out based on dependencies which modules need to be
rebuilt, without always building everything.
R6.tar
file.
$ make clean
$ make package
Makefile
are for:
default
clean
package