CptS 122 – Data Structures                                                                                             

 

Programming Assignment 2: Fun with Arrays, Strings, and Pointers (Continued)

 

Assigned: Wednesday, September 05, 2012

Due: Friday, September 14, 2012 by midnight


Many of you were not able to complete all the tasks in Lab1, so you should complete those tasks as the part of this programming assignment 2. If you had managed to complete the following tasks in Lab 1, you should still submit your code as part of this assignment to get credit for programming assignment 2.

I. Learner Objectives:

 

At the conclusion of this programming assignment, participants should be able to:

 

II. Prerequisites:

 

Before starting this programming assignment, participants should be able to:

 

III. Overview & Requirements:

For each of the following problems create a separate Microsoft VS 2008 project. Within each project you must have at least one header file (.h) and two source files (.c). Before you turn in this assignment, be sure to place each project folder into a single <your last name>_pa2 folder.

 

1. Write a C program that merges two strings such that the words in the final string are in sorted order. The original two strings will not necessarily have their words in sorted order to begin with. For example, your starting strings could be “it is raining” and “computer science lab”. The merged version in this case would be “computer is it lab raining science”. As an even simpler example, consider the starting strings “cat apple” and “dog avocado”. The merged version in this case would be “apple avocado cat dog”. You will need to merge the two strings into a third, dynamically allocated array.


2. Write a C program which reads characters from a file and determines the number of each character, and the line of which each one is found, in the file. Assume the file consists of alphabetic characters only. You may NOT use if statements to “count” each character. For example, if the file contents are: 

This is a file 

It has 3 lines 

This is the third 

Then the output should be something like the following:

t – occurs 5 times in the file, on lines 1, 2, and 3  


IV. Submitting Assignments:

 

  1. Using the Angel tool https://lms.wsu.edu submit your assignment to your TA. You will "drop" your solution into the provided "Homework Submissions" Drop Box under the "Lessons" tab. You must upload your solutions as <your last name>_pa2.zip by the due date and time.
  2. Your .zip file should contain multiple project workspaces. Each project must have at least one header file (a .h file), two C source files (which must be .c files), and project workspace. Delete the debug folder before you zip your project folders.
  3. Your projects must build properly. The most points an assignment can receive if it does not build properly is 50 out of 100.

 

V. Grading Guidelines:

 

This assignment is worth 100 points. Your assignment will be evaluated based on a successful compilation and adherence to the program requirements. We will grade according to the following criteria: