CSCI 1120 (Low-Level Computing), Spring 2015:
Homework 1

Credit:
10 points.

Reading

Be sure you have read the assigned readings for classes through 1/28.

Programming Problems

Do the following programming problems. You will end up with at least one file per problem (text for the first problem, source code for the second). Submit these 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 1''). You can do this assignment on any system that provides the needed functionality, but I will test the program on one of the department's Linux machines, so you should probably make sure it works in that environment before turning it in.

  1. (5 points) (Not really a programming problem, but one that requires you to use a computer.) For this problem your mission is to learn a little more about traditional UNIX text editors vi and/or emacs. Do one or both of the following (full credit for doing one, extra credit if you do both). (Note that I assign this problem in several of my courses, so if you have already done it for another course, please go beyond what you did for the other course.)

    Turn in the resulting text file(s).

  2. (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 can make 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-01-30