CSCI 1120 (Low-Level Computing), Spring 2010:
Homework 3

Credit:
10 points.

Reading

Be sure you have read, or at least skimmed, the readings for 2/22, linked from the ``Lecture topics and assignments'' page.

Programming Problems

Do the following programming problems. You will end up with at least one code file per problem. Submit your program source 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 3''). 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) Write a C function that takes a character string as input and prints the string and, for each possible character, how many times it occurs in the string. Print counts only for the characters actually present. Also write a short main program that calls your function a few times with inputs showing that it works. Sample output might look something like the following:
    input:
    hello world 1234 !@#$
    
    count for character 32 ( ) is 3
    count for character 33 (!) is 1
    count for character 35 (#) is 1
    count for character 36 ($) is 1
    count for character 49 (1) is 1
    count for character 50 (2) is 1
    count for character 51 (3) is 1
    count for character 52 (4) is 1
    count for character 64 (@) is 1
    count for character 100 (d) is 1
    count for character 101 (e) is 1
    count for character 104 (h) is 1
    count for character 108 (l) is 3
    count for character 111 (o) is 2
    count for character 114 (r) is 1
    count for character 119 (w) is 1
    
    input:
    Now is the time for all good persons to come to the aid of their party.
    
    count for character 32 ( ) is 15
    count for character 46 (.) is 1
    count for character 78 (N) is 1
    count for character 97 (a) is 3
    count for character 99 (c) is 1
    count for character 100 (d) is 2
    count for character 101 (e) is 6
    count for character 102 (f) is 2
    count for character 103 (g) is 1
    count for character 104 (h) is 3
    count for character 105 (i) is 4
    count for character 108 (l) is 2
    count for character 109 (m) is 2
    count for character 110 (n) is 1
    count for character 111 (o) is 9
    count for character 112 (p) is 2
    count for character 114 (r) is 4
    count for character 115 (s) is 3
    count for character 116 (t) is 7
    count for character 119 (w) is 1
    count for character 121 (y) is 1
    

    Hints:



Berna Massingill
2010-03-10