Classwork 21
Logistics
- Due: Friday, April 5th AoE.
- Submission instructions: make sure that the required files are in your
csci112_spring2024/classwork/week12/fri/
directory. - Deadline reminder: after the deadline passes, you cannot earn any points for this assignment.
Learning outcomes
- Practice using pointers to structs
Assignment
- Log in to the server.
- From your home directory, navigate to
csci112_spring2024/classwork/week12/fri/
, creating directoriesweek12
andfri
if necessary. - Copy
main.c
,planet.c
,sort.c
,planet.h
,sort.h
, andMakefile
from/public/classwork/week12/fri/
.
Fill in the TODO
s in main.c
so that when you compile and run the program,
you get:
[g73x595@csci112 fri]$ make
gcc -c main.c -Wall
gcc -c planet.c -Wall
gcc -c sort.c -Wall
gcc main.o planet.o sort.o -Wall
[g73x595@csci112 fri]$ ./a.out
The planets are:
Mercury: 4879 diameter, 0 moons, 0.25 orbit time, 1426.00 rot. time
Venus: 12104 diameter, 0 moons, 0.62 orbit time, 5832.00 rot. time
Earth: 12756 diameter, 1 moons, 1.00 orbit time, 24.00 rot. time
Mars: 6779 diameter, 2 moons, 1.88 orbit time, 24.61 rot. time
Jupiter: 142800 diameter, 16 moons, 11.90 orbit time, 9.93 rot. time
Saturn: 120536 diameter, 146 moons, 29.40 orbit time, 10.70 rot. time
Uranus: 50000 diameter, 27 moons, 84.00 orbit time, 17.23 rot. time
Neptune: 49528 diameter, 14 moons, 165.00 orbit time, 16.10 rot. time
Sorted by diameter, they are:
Mercury: 4879 diameter, 0 moons, 0.25 orbit time, 1426.00 rot. time
Mars: 6779 diameter, 2 moons, 1.88 orbit time, 24.61 rot. time
Venus: 12104 diameter, 0 moons, 0.62 orbit time, 5832.00 rot. time
Earth: 12756 diameter, 1 moons, 1.00 orbit time, 24.00 rot. time
Neptune: 49528 diameter, 14 moons, 165.00 orbit time, 16.10 rot. time
Uranus: 50000 diameter, 27 moons, 84.00 orbit time, 17.23 rot. time
Saturn: 120536 diameter, 146 moons, 29.40 orbit time, 10.70 rot. time
Jupiter: 142800 diameter, 16 moons, 11.90 orbit time, 9.93 rot. time
Sorted by name, they are:
Earth: 12756 diameter, 1 moons, 1.00 orbit time, 24.00 rot. time
Jupiter: 142800 diameter, 16 moons, 11.90 orbit time, 9.93 rot. time
Mars: 6779 diameter, 2 moons, 1.88 orbit time, 24.61 rot. time
Mercury: 4879 diameter, 0 moons, 0.25 orbit time, 1426.00 rot. time
Neptune: 49528 diameter, 14 moons, 165.00 orbit time, 16.10 rot. time
Saturn: 120536 diameter, 146 moons, 29.40 orbit time, 10.70 rot. time
Uranus: 50000 diameter, 27 moons, 84.00 orbit time, 17.23 rot. time
Venus: 12104 diameter, 0 moons, 0.62 orbit time, 5832.00 rot. time
Autograder
You can run the autograder by running
/public/classwork/week12/fri/autograder.sh
The file autograder.txt
will be created with your score.
Grading turnaround
The autograder will be run at 6am to calculate final scores. Scores will be uploaded to D2L by the next class period.