CSCI 1120 (Low-Level Computing), Fall 2015:
Homework 2

Credit:
5 points.

Reading

Be sure you have read the assigned readings for classes through 9/09.

Programming Problems

Do the following programming problems. You will end up with at least one code file per problem. Submit your program source (and any other needed files) by sending mail to bmassing@cs.trinity.edu, with each file as an attachment. Please use a subject line that mentions the course number and the assignment (e.g., ``csci 1120 homework 2''). You can develop your programs on any system that provides the needed functionality, but I will test them on one of the department's Linux machines, so you should probably make sure they work in that environment before turning them in.

  1. (5 points) Write a C program to convert seconds into years, days, hours, minutes, and seconds. Your program should prompt the user for a number of seconds, get the number entered, and print the equivalent number of years, days, etc. (e.g., 100 seconds is 0 years, 0 days, 0 hours, 1 minute, and 40 seconds). Assume 365 days in a year (not quite right but makes the calculations simpler). For this assignment only, you do not need to do any kind of checking that what the user enters is actually an integer and non-negative, since we haven't yet talked about conditional execution. Just assume it is and do the required calculations.

    Hint: Probably the best way to do the required calculations is with integer-division (/) and remainder (%) operators.



Berna Massingill
2015-09-09