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

Credit:
20 points.

Reading

Be sure you have read the assigned readings for classes through 3/18.

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 4''). 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. (10 points) In CSCI 1320 you probably learned about sorting algorithms and implemented one or more of them. A simple way to test such an algorithm is to generate a sequence of ``random'' numbers, sort them, and check that the result is in ascending order. Sample program sort-starter.c shows how this might be done in C (leaving out the actual sorting). For this problem you will do two things:

    Hints:

  2. (10 points) A very simple way to encrypt text is to rotate each alphabetic character $ N$ positions. For example, if $ N$ is 1, ``abc XYZ 1234'' becomes ``bcd YZA 1234''. (This is obviously not industrial-strength encryption but is good enough to somewhat obscure the plaintext.) Write a C program that implements this scheme. The program should take three command-line arguments: the number of positions to rotate (which for simplicity should be a positive integer), the name of the input file, and the name of the output file. It should print error messages as appropriate (not enough command-line arguments, non-numeric $ N$ , input or output files cannot be opened). For valid arguments, it should encrypt the input file and write the result to the output file. To get full credit, your program should encrypt characters as discussed in the hint below.

    Hints:



Berna Massingill
2015-03-20